Class: Primalize::Single::Enum
- Inherits:
-
Object
- Object
- Primalize::Single::Enum
- Includes:
- Type
- Defined in:
- lib/primalize/single.rb
Constant Summary
Constants included from Type
Instance Method Summary collapse
- #===(value) ⇒ Object
- #coerce(value) ⇒ Object
-
#initialize(values, &coercion) ⇒ Enum
constructor
A new instance of Enum.
- #inspect ⇒ Object
Constructor Details
#initialize(values, &coercion) ⇒ Enum
Returns a new instance of Enum.
266 267 268 269 |
# File 'lib/primalize/single.rb', line 266 def initialize values, &coercion @values = values @coercion = coercion end |
Instance Method Details
#===(value) ⇒ Object
271 272 273 |
# File 'lib/primalize/single.rb', line 271 def === value @values.include? value end |
#coerce(value) ⇒ Object
275 276 277 |
# File 'lib/primalize/single.rb', line 275 def coerce value super value, @values end |
#inspect ⇒ Object
279 280 281 |
# File 'lib/primalize/single.rb', line 279 def inspect "enum(#{@values.map(&:inspect).join(', ')})" end |