Class: Contracts::Builtin::Enum
- Inherits:
-
CallableClass
- Object
- CallableClass
- Contracts::Builtin::Enum
- Defined in:
- lib/contracts/builtin_contracts.rb
Overview
Takes a list of values, e.g. [:a, :b, :c]. If argument is included in the list, the contract passes.
Example: Enum[:a, :b, :c]
?
Instance Method Summary collapse
-
#initialize(*vals) ⇒ Enum
constructor
A new instance of Enum.
- #valid?(val) ⇒ Boolean
Methods inherited from CallableClass
Constructor Details
#initialize(*vals) ⇒ Enum
Returns a new instance of Enum.
238 239 240 241 |
# File 'lib/contracts/builtin_contracts.rb', line 238 def initialize(*vals) super() @vals = vals end |
Instance Method Details
#valid?(val) ⇒ Boolean
243 244 245 |
# File 'lib/contracts/builtin_contracts.rb', line 243 def valid?(val) @vals.include? val end |