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: 44,053 of 183,127
Downloads: 23,881
Daily
Ranking: 74,510 of 183,106
Downloads: 0
Downloads Trends
Ranking Trends
Num of Versions Trends
Popular Versions (Major)
Popular Versions (Major.Minor)
Depended by
Rank | Downloads | Name |
---|---|---|
21,592 | 62,987 | prick |
23,089 | 57,143 | shellopts |
64,903 | 14,119 | pg_graph |
91,050 | 8,359 | modular_tree |
92,391 | 8,186 | qrpm |
103,468 | 6,770 | fixture_fox |
115,807 | 5,430 | postspec |
177,520 | 970 | sqlsnip |
179,890 | 558 | dumps |
Depends on
Rank | Downloads | Name |
---|---|---|
99 | 348,471,616 | simplecov |
Owners
# | Gravatar | Handle |
---|---|---|
1 | clrgem |