Class: TinyFRP::Split

Inherits:
Node
  • Object
show all
Defined in:
lib/tiny_frp.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#*, #**, #+, #<<, #>>, #call

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

#nodesObject (readonly)

Returns the value of attribute nodes.



157
158
159
# File 'lib/tiny_frp.rb', line 157

def nodes
  @nodes
end

Instance Method Details

#argcObject



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