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,209 of 192,666
Downloads: 30,211
Daily
Ranking: 18,003 of 192,588
Downloads: 44
Downloads Trends
Ranking Trends
Num of Versions Trends
Popular Versions (Major)
Popular Versions (Major.Minor)
Depended by
| Rank | Downloads | Name |
|---|---|---|
| 18,843 | 93,828 | prick |
| 21,062 | 78,283 | shellopts |
| 56,484 | 19,689 | pg_graph |
| 77,738 | 12,462 | fixture_fox |
| 80,289 | 11,873 | postspec |
| 80,364 | 11,854 | modular_tree |
| 80,538 | 11,813 | qrpm |
| 171,254 | 2,635 | sqlsnip |
| 185,059 | 978 | dumps |
Depends on
| Rank | Downloads | Name |
|---|---|---|
| 99 | 464,871,551 | simplecov |
Owners
| # | Gravatar | Handle |
|---|---|---|
| 1 | clrgem |