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,384 of 198,430
Downloads: 35,170
Daily
Ranking: 28,714 of 198,401
Downloads: 6
Downloads Trends
Ranking Trends
Num of Versions Trends
Popular Versions (Major)
Popular Versions (Major.Minor)
Depended by
| Rank | Downloads | Name |
|---|---|---|
| 17,832 | 111,851 | prick |
| 19,979 | 92,136 | shellopts |
| 55,084 | 21,560 | pg_graph |
| 74,944 | 13,921 | postspec |
| 75,062 | 13,888 | fixture_fox |
| 77,324 | 13,291 | qrpm |
| 79,224 | 12,812 | modular_tree |
| 170,366 | 3,004 | sqlsnip |
| 189,603 | 1,106 | dumps |
Depends on
| Rank | Downloads | Name |
|---|---|---|
| 97 | 518,966,733 | simplecov |
Owners
| # | Gravatar | Handle |
|---|---|---|
| 1 | clrgem |