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: 38,433 of 197,085
Downloads: 34,695
Daily
Ranking: 11,442 of 197,066
Downloads: 41
Downloads Trends
Ranking Trends
Num of Versions Trends
Popular Versions (Major)
Popular Versions (Major.Minor)
Depended by
| Rank | Downloads | Name |
|---|---|---|
| 18,007 | 107,995 | prick |
| 19,996 | 90,383 | shellopts |
| 55,117 | 21,279 | pg_graph |
| 75,374 | 13,658 | fixture_fox |
| 75,863 | 13,522 | postspec |
| 77,526 | 13,099 | qrpm |
| 79,110 | 12,691 | modular_tree |
| 170,200 | 2,955 | sqlsnip |
| 189,046 | 1,073 | dumps |
Depends on
| Rank | Downloads | Name |
|---|---|---|
| 98 | 505,778,426 | simplecov |
Owners
| # | Gravatar | Handle |
|---|---|---|
| 1 | clrgem |