Categories: None [Edit]
constrain
Allows you check if an object match a class expression. It is typically
used to check the type of method paraameters. It is an alternative to using
Ruby-3 .rbs files but with a different syntax and only dynamic checks
Typically you'll include the Constrain module and use #constrain to check
the type of method parameters:
include Constrain
# f takes a String and an array of Integer objects. Raise a Constrain::Error
# if parameters doesn't have the expected types
def f(a, b)
constrain a, String
constrain b, [Integer]
end
Constrain works with ruby-2 (and maybe ruby-3)
Total
Ranking: 41,510 of 187,224
Downloads: 28,095
Daily
Ranking: 22,950 of 187,196
Downloads: 42
Downloads Trends
Ranking Trends
Num of Versions Trends
Popular Versions (Major)
Popular Versions (Major.Minor)
Depended by
Rank | Downloads | Name |
---|---|---|
19,713 | 80,147 | prick |
21,730 | 68,763 | shellopts |
59,311 | 17,359 | pg_graph |
83,100 | 10,585 | fixture_fox |
83,932 | 10,405 | modular_tree |
84,684 | 10,246 | qrpm |
89,072 | 9,409 | postspec |
176,427 | 1,913 | sqlsnip |
182,183 | 807 | dumps |
Depends on
Rank | Downloads | Name |
---|---|---|
99 | 421,067,602 | simplecov |
Owners
# | Gravatar | Handle |
---|---|---|
1 | clrgem |