Class: TinyFRP::Split
Instance Attribute Summary collapse
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
Instance Method Summary collapse
- #argc ⇒ Object
- #calc(memo, last_memo, *args) ⇒ Object
-
#initialize(*nodes) ⇒ Split
constructor
A new instance of Split.
Methods inherited from Node
Constructor Details
#initialize(*nodes) ⇒ Split
Returns a new instance of Split.
159 160 161 |
# File 'lib/tiny_frp.rb', line 159 def initialize(*nodes) @nodes = nodes end |
Instance Attribute Details
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
157 158 159 |
# File 'lib/tiny_frp.rb', line 157 def nodes @nodes end |
Instance Method Details
#argc ⇒ Object
163 164 165 |
# File 'lib/tiny_frp.rb', line 163 def argc @argc ||= @nodes.first.argc end |
#calc(memo, last_memo, *args) ⇒ Object
167 168 169 170 |
# File 'lib/tiny_frp.rb', line 167 def calc(memo, last_memo, *args) res = @nodes.inject(memo){|acc, n| n.call(acc, last_memo, *args)} res.merge(self => @nodes.inject([]){|acc, n| acc + res[n]}) end |