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,959 of 186,959
Downloads: 27,106
Daily
Ranking: 26,378 of 186,713
Downloads: 29
Downloads Trends
Ranking Trends
Num of Versions Trends
Popular Versions (Major)
Popular Versions (Major.Minor)
Depended by
Rank | Downloads | Name |
---|---|---|
20,384 | 74,640 | prick |
22,357 | 64,603 | shellopts |
60,893 | 16,365 | pg_graph |
86,486 | 9,655 | modular_tree |
86,800 | 9,595 | qrpm |
87,375 | 9,488 | fixture_fox |
95,085 | 8,302 | postspec |
177,651 | 1,525 | sqlsnip |
181,815 | 719 | dumps |
Depends on
Rank | Downloads | Name |
---|---|---|
99 | 413,507,374 | simplecov |
Owners
# | Gravatar | Handle |
---|---|---|
1 | clrgem |