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: 45,281 of 180,661
Downloads: 21,942
Daily
Ranking: 16,801 of 180,641
Downloads: 22
Downloads Trends
Ranking Trends
Num of Versions Trends
Popular Versions (Major)
Popular Versions (Major.Minor)
Depended by
Rank | Downloads | Name |
---|---|---|
23,555 | 52,424 | shellopts |
23,818 | 51,669 | prick |
71,540 | 11,669 | pg_graph |
99,966 | 6,918 | modular_tree |
101,071 | 6,765 | qrpm |
121,669 | 4,652 | fixture_fox |
135,710 | 3,856 | postspec |
178,606 | 437 | dumps |
Depends on
Rank | Downloads | Name |
---|---|---|
101 | 314,244,003 | simplecov |
Owners
# | Gravatar | Handle |
---|---|---|
1 | clrgem |