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,280 of 192,062
Downloads: 29,938
Daily
Ranking: 18,954 of 192,034
Downloads: 46
Downloads Trends
Ranking Trends
Num of Versions Trends
Popular Versions (Major)
Popular Versions (Major.Minor)
Depended by
| Rank | Downloads | Name |
|---|---|---|
| 18,816 | 92,335 | prick |
| 21,172 | 76,337 | shellopts |
| 56,730 | 19,435 | pg_graph |
| 78,177 | 12,274 | fixture_fox |
| 80,600 | 11,714 | modular_tree |
| 80,886 | 11,653 | postspec |
| 81,042 | 11,619 | qrpm |
| 171,923 | 2,558 | sqlsnip |
| 184,755 | 957 | dumps |
Depends on
| Rank | Downloads | Name |
|---|---|---|
| 99 | 459,446,383 | simplecov |
Owners
| # | Gravatar | Handle |
|---|---|---|
| 1 | clrgem |