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,204 of 188,299
Downloads: 28,947
Daily
Ranking: 14,933 of 188,294
Downloads: 9
Downloads Trends
Ranking Trends
Num of Versions Trends
Popular Versions (Major)
Popular Versions (Major.Minor)
Depended by
| Rank | Downloads | Name |
|---|---|---|
| 19,263 | 85,226 | prick |
| 21,417 | 71,990 | shellopts |
| 58,020 | 18,266 | pg_graph |
| 80,339 | 11,404 | fixture_fox |
| 82,669 | 10,909 | modular_tree |
| 83,072 | 10,818 | qrpm |
| 84,674 | 10,481 | postspec |
| 175,244 | 2,181 | sqlsnip |
| 182,960 | 891 | dumps |
Depends on
| Rank | Downloads | Name |
|---|---|---|
| 99 | 433,034,919 | simplecov |
Owners
| # | Gravatar | Handle |
|---|---|---|
| 1 | clrgem |