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: 43,890 of 183,477
Downloads: 24,152
Daily
Ranking: 11,043 of 183,470
Downloads: 15
Downloads Trends
Ranking Trends
Num of Versions Trends
Popular Versions (Major)
Popular Versions (Major.Minor)
Depended by
Rank | Downloads | Name |
---|---|---|
21,426 | 64,199 | prick |
23,021 | 57,750 | shellopts |
64,453 | 14,361 | pg_graph |
90,149 | 8,552 | modular_tree |
91,356 | 8,366 | qrpm |
102,456 | 6,954 | fixture_fox |
114,408 | 5,622 | postspec |
177,507 | 1,030 | sqlsnip |
180,044 | 580 | dumps |
Depends on
Rank | Downloads | Name |
---|---|---|
98 | 353,748,210 | simplecov |
Owners
# | Gravatar | Handle |
---|---|---|
1 | clrgem |