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,213 of 189,899
Downloads: 29,467
Daily
Ranking: 37,125 of 189,874
Downloads: 4
Downloads Trends
Ranking Trends
Num of Versions Trends
Popular Versions (Major)
Popular Versions (Major.Minor)
Depended by
| Rank | Downloads | Name |
|---|---|---|
| 18,933 | 89,753 | prick |
| 21,247 | 74,569 | shellopts |
| 57,133 | 18,927 | pg_graph |
| 78,979 | 11,892 | fixture_fox |
| 81,332 | 11,374 | modular_tree |
| 81,731 | 11,289 | qrpm |
| 81,870 | 11,258 | postspec |
| 172,595 | 2,439 | sqlsnip |
| 183,905 | 921 | dumps |
Depends on
| Rank | Downloads | Name |
|---|---|---|
| 99 | 447,225,906 | simplecov |
Owners
| # | Gravatar | Handle |
|---|---|---|
| 1 | clrgem |