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,148 of 188,779
Downloads: 29,211
Daily
Ranking: 55,176 of 188,757
Downloads: 1
Downloads Trends
Ranking Trends
Num of Versions Trends
Popular Versions (Major)
Popular Versions (Major.Minor)
Depended by
| Rank | Downloads | Name |
|---|---|---|
| 19,105 | 87,132 | prick |
| 21,361 | 72,994 | shellopts |
| 57,650 | 18,530 | pg_graph |
| 79,398 | 11,678 | fixture_fox |
| 82,441 | 11,034 | modular_tree |
| 82,726 | 10,972 | qrpm |
| 82,903 | 10,932 | postspec |
| 174,819 | 2,245 | sqlsnip |
| 183,421 | 907 | dumps |
Depends on
| Rank | Downloads | Name |
|---|---|---|
| 99 | 437,166,465 | simplecov |
Owners
| # | Gravatar | Handle |
|---|---|---|
| 1 | clrgem |