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,125 of 189,321
Downloads: 29,379
Daily
Ranking: 32,122 of 189,284
Downloads: 2
Downloads Trends
Ranking Trends
Num of Versions Trends
Popular Versions (Major)
Popular Versions (Major.Minor)
Depended by
| Rank | Downloads | Name |
|---|---|---|
| 19,012 | 88,535 | prick |
| 21,314 | 73,718 | shellopts |
| 57,413 | 18,715 | pg_graph |
| 79,105 | 11,807 | fixture_fox |
| 81,887 | 11,201 | modular_tree |
| 82,170 | 11,139 | qrpm |
| 82,429 | 11,088 | postspec |
| 174,086 | 2,322 | sqlsnip |
| 183,674 | 918 | dumps |
Depends on
| Rank | Downloads | Name |
|---|---|---|
| 99 | 442,543,989 | simplecov |
Owners
| # | Gravatar | Handle |
|---|---|---|
| 1 | clrgem |