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,145 of 193,214
Downloads: 30,464
Daily
Ranking: 37,933 of 193,188
Downloads: 7
Downloads Trends
Ranking Trends
Num of Versions Trends
Popular Versions (Major)
Popular Versions (Major.Minor)
Depended by
| Rank | Downloads | Name |
|---|---|---|
| 18,759 | 95,348 | prick |
| 20,897 | 80,014 | shellopts |
| 56,070 | 20,026 | pg_graph |
| 77,056 | 12,715 | fixture_fox |
| 79,538 | 12,119 | postspec |
| 79,636 | 12,097 | modular_tree |
| 79,967 | 12,029 | qrpm |
| 170,344 | 2,720 | sqlsnip |
| 185,354 | 995 | dumps |
Depends on
| Rank | Downloads | Name |
|---|---|---|
| 97 | 470,376,754 | simplecov |
Owners
| # | Gravatar | Handle |
|---|---|---|
| 1 | clrgem |