R
Ryan Pavlik
StrongTyping 2.0.6a
===================
StrongTyping is a little ruby module that provides a convenient way
for ruby methods to check parameter types, and also dynamically
query them. In addition to merely checking a single set of types,
it allows easy overloading based on a number of different templates.
For example:
require 'strongtyping'
include StrongTyping
def foo(a, b, c)
expect(a, String, b, Numeric, c, [Integer, NilClass])
...
end
def bar(*args)
overload(args, String, String) {
| s1, s2 |
...
return
}
overload(args, String, Integer) {
| s, i |
...
return
}
overload_default args
end
You can find StrongTyping at the following location:
http://mephle.org/StrongTyping/
(This has been around for awhile, but as Mephle is being released and
people may not have seen it, I decided now would be an appropriate
time.)
===================
StrongTyping is a little ruby module that provides a convenient way
for ruby methods to check parameter types, and also dynamically
query them. In addition to merely checking a single set of types,
it allows easy overloading based on a number of different templates.
For example:
require 'strongtyping'
include StrongTyping
def foo(a, b, c)
expect(a, String, b, Numeric, c, [Integer, NilClass])
...
end
def bar(*args)
overload(args, String, String) {
| s1, s2 |
...
return
}
overload(args, String, Integer) {
| s, i |
...
return
}
overload_default args
end
You can find StrongTyping at the following location:
http://mephle.org/StrongTyping/
(This has been around for awhile, but as Mephle is being released and
people may not have seen it, I decided now would be an appropriate
time.)