Class: Monadist::List
Instance Attribute Summary collapse
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Class Method Summary collapse
Instance Method Summary collapse
- #bind(&block) ⇒ Object
-
#initialize(values) ⇒ List
constructor
A new instance of List.
Methods inherited from Monad
Constructor Details
#initialize(values) ⇒ List
Returns a new instance of List.
8 9 10 |
# File 'lib/monadist/list.rb', line 8 def initialize(values) @values = values end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Monadist::Monad
Instance Attribute Details
#values ⇒ Object (readonly)
Returns the value of attribute values.
4 5 6 |
# File 'lib/monadist/list.rb', line 4 def values @values end |
Class Method Details
.unit(value) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/monadist/list.rb', line 20 def self.unit(value) if value.is_a? Array new value else new [value] end end |
Instance Method Details
#bind(&block) ⇒ Object
14 15 16 |
# File 'lib/monadist/list.rb', line 14 def bind(&block) self.class.new values.map(&block).flat_map(&:values) end |