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,187 of 191,254
Downloads: 29,659
Daily
Ranking: 26,080 of 191,174
Downloads: 6
Downloads Trends
Ranking Trends
Num of Versions Trends
Popular Versions (Major)
Popular Versions (Major.Minor)
Depended by
| Rank | Downloads | Name |
|---|---|---|
| 18,888 | 90,880 | prick |
| 21,203 | 75,331 | shellopts |
| 56,894 | 19,138 | pg_graph |
| 78,621 | 12,037 | fixture_fox |
| 81,019 | 11,505 | modular_tree |
| 81,276 | 11,445 | postspec |
| 81,317 | 11,437 | qrpm |
| 172,331 | 2,484 | sqlsnip |
| 184,198 | 939 | dumps |
Depends on
| Rank | Downloads | Name |
|---|---|---|
| 99 | 453,302,650 | simplecov |
Owners
| # | Gravatar | Handle |
|---|---|---|
| 1 | clrgem |