Class: TinyFRP::Node

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

Direct Known Subclasses

Foldp, Lift

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fixed_argcObject (readonly)

Returns the value of attribute fixed_argc.



66
67
68
# File 'lib/tiny_frp.rb', line 66

def fixed_argc
  @fixed_argc
end

Instance Method Details

#>>(node) ⇒ Object



68
69
70
# File 'lib/tiny_frp.rb', line 68

def >>(node)
  node.apply([self])
end

#apply(args) ⇒ Object



72
73
74
75
76
77
78
79
80
81
# File 'lib/tiny_frp.rb', line 72

def apply(args)
  signals = args.map{|s| s.is_a?(Node) && s.fixed_argc == 0 ? Signal.new(s, []) : s}
  if signals.any?{|s| !s.is_a?(Signal)}
    raise "Error: cannot apply SignalFunction to Non-Signal Object."
  end
  if signals.size < @fixed_argc || (!@rest_arg && signals.size != @fixed_argc)
    raise "Error: cannot apply SignalFunction to Signals."
  end
  Signal.new(self, signals)
end