Class: ActsAsGraphDiagram::Nodes

Inherits:
Array
  • Object
show all
Defined in:
lib/acts_as_graph_diagram/node/graph_calculator.rb

Overview

This module represents a array of node.

Instance Method Summary collapse

Instance Method Details

#appendObject

Returns Proc.

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

#confluenceObject

Returns Proc.

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.

Parameters:

  • functional (Proc)
  • values (Nodes)

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.

Parameters:

  • functional (Proc)
  • meta (Proc)
  • value (Any)
  • operator (Symbol)

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, meta, value, operator)
  return value if !defined?(empty?) || empty?

  meta[
    first.destination.recurse_apply(functional, meta, value, operator),
    ActsAsGraphDiagram::Nodes.new(tail)
                             .recurse_apply(functional, meta, value, operator)
  ]
end

#tailObject

Returns Array.

Returns:

  • Array



34
35
36
# File 'lib/acts_as_graph_diagram/node/graph_calculator.rb', line 34

def tail
  drop 1
end