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,350 of 187,950
Downloads: 28,600
Daily
Ranking: 25,453 of 187,922
Downloads: 31
Downloads Trends
Ranking Trends
Num of Versions Trends
Popular Versions (Major)
Popular Versions (Major.Minor)
Depended by
| Rank | Downloads | Name |
|---|---|---|
| 19,377 | 83,556 | prick |
| 21,563 | 70,557 | shellopts |
| 58,660 | 17,864 | pg_graph |
| 81,374 | 11,090 | fixture_fox |
| 83,408 | 10,676 | modular_tree |
| 83,849 | 10,575 | qrpm |
| 86,060 | 10,114 | postspec |
| 175,916 | 2,065 | sqlsnip |
| 182,636 | 857 | dumps |
Depends on
| Rank | Downloads | Name |
|---|---|---|
| 99 | 428,731,506 | simplecov |
Owners
| # | Gravatar | Handle |
|---|---|---|
| 1 | clrgem |