Class: Nodes::Path
- Inherits:
-
Object
- Object
- Nodes::Path
- Defined in:
- lib/appswarm/routing/routing.rb
Instance Attribute Summary collapse
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
Instance Method Summary collapse
- #<<(node) ⇒ Object
-
#initialize(from) ⇒ Path
constructor
A new instance of Path.
- #initialize_copy(s) ⇒ Object
-
#last ⇒ Object
Path.new(@nodes.clone).
- #to_s ⇒ Object
- #value ⇒ Object
Constructor Details
Instance Attribute Details
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
101 102 103 |
# File 'lib/appswarm/routing/routing.rb', line 101 def nodes @nodes end |
Instance Method Details
#<<(node) ⇒ Object
109 110 111 |
# File 'lib/appswarm/routing/routing.rb', line 109 def <<(node) @nodes << node end |
#initialize_copy(s) ⇒ Object
122 123 124 125 126 127 |
# File 'lib/appswarm/routing/routing.rb', line 122 def initialize_copy(s) #puts "S:",*s,s #exit @nodes=s.nodes.clone #Path.new(@nodes.clone) end |
#last ⇒ Object
Path.new(@nodes.clone)
128 129 130 |
# File 'lib/appswarm/routing/routing.rb', line 128 def last @nodes[-1] end |
#to_s ⇒ Object
131 132 133 |
# File 'lib/appswarm/routing/routing.rb', line 131 def to_s "[#{@nodes.length} - #{value}]" end |
#value ⇒ Object
112 113 114 115 116 117 118 119 120 121 |
# File 'lib/appswarm/routing/routing.rb', line 112 def value a=(1..(@nodes.length-1)).to_a val=a.inject(0){|old,i| a=@nodes[i-1] b=@nodes[i] old.to_i+a.distance(b).to_i } val end |