Class: ActsAsGraphDiagram::Nodes
- Inherits:
-
Array
- Object
- Array
- ActsAsGraphDiagram::Nodes
- Defined in:
- lib/acts_as_graph_diagram/node/graph_calculator.rb
Overview
This module represents a array of node.
Instance Method Summary collapse
-
#append ⇒ Object
Proc.
-
#confluence ⇒ Object
Proc.
-
#linear(functional, values) ⇒ Object
Proc.
-
#recurse_apply(functional, meta, value, operator) ⇒ Object
Any.
-
#tail ⇒ Object
Array.
Instance Method Details
#append ⇒ Object
Returns Proc.
48 49 50 51 52 53 54 55 |
# File 'lib/acts_as_graph_diagram/node/graph_calculator.rb', line 48 def append # @param [Proc] functional # @param [Nodes] values lambda do |nodes = self, list| nodes.linear confluence, ActsAsGraphDiagram::Nodes.new(list) end end |
#confluence ⇒ Object
Returns Proc.
39 40 41 42 43 44 45 |
# File 'lib/acts_as_graph_diagram/node/graph_calculator.rb', line 39 def confluence # @param [Proc] functional # @param [Nodes] values lambda do |x, list = self| ActsAsGraphDiagram::Nodes.new([x] + list) end end |
#linear(functional, values) ⇒ Object
Returns Proc.
25 26 27 28 29 30 31 |
# File 'lib/acts_as_graph_diagram/node/graph_calculator.rb', line 25 def linear(functional, values) return self if empty? || !first.attributes.include?(:destination) functional[first.destination, ActsAsGraphDiagram::Nodes.new(tail) .linear(functional, values)] end |
#recurse_apply(functional, meta, value, operator) ⇒ Object
Returns Any.
12 13 14 15 16 17 18 19 20 |
# File 'lib/acts_as_graph_diagram/node/graph_calculator.rb', line 12 def recurse_apply(functional, , value, operator) return value if !defined?(empty?) || empty? [ first.destination.recurse_apply(functional, , value, operator), ActsAsGraphDiagram::Nodes.new(tail) .recurse_apply(functional, , value, operator) ] end |
#tail ⇒ Object
Returns Array.
34 35 36 |
# File 'lib/acts_as_graph_diagram/node/graph_calculator.rb', line 34 def tail drop 1 end |