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.
223 224 225 |
# File 'lib/contracts/builtin_contracts.rb', line 223 def initialize(*vals) @vals = vals end |
Instance Method Details
#valid?(val) ⇒ Boolean
227 228 229 |
# File 'lib/contracts/builtin_contracts.rb', line 227 def valid?(val) @vals.include? val end |