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,171 of 193,756
Downloads: 30,585
Daily
Ranking: 71,816 of 193,649
Downloads: 1
Downloads Trends
Ranking Trends
Num of Versions Trends
Popular Versions (Major)
Popular Versions (Major.Minor)
Depended by
| Rank | Downloads | Name |
|---|---|---|
| 18,754 | 96,086 | prick |
| 20,864 | 80,847 | shellopts |
| 55,992 | 20,147 | pg_graph |
| 77,034 | 12,780 | fixture_fox |
| 79,440 | 12,193 | postspec |
| 79,581 | 12,161 | modular_tree |
| 79,879 | 12,093 | qrpm |
| 170,336 | 2,738 | sqlsnip |
| 185,611 | 998 | dumps |
Depends on
| Rank | Downloads | Name |
|---|---|---|
| 97 | 475,839,609 | simplecov |
Owners
| # | Gravatar | Handle |
|---|---|---|
| 1 | clrgem |