Class: Graph::EdgeArray
- Inherits:
-
Array
- Object
- Array
- Graph::EdgeArray
- Defined in:
- lib/graph.rb
Overview
An array of Edge objects
Instance Method Summary collapse
-
#initialize(li) ⇒ EdgeArray
constructor
Create a new
EdgeArray
from an existingArray
. -
#push(e) ⇒ EdgeArray
Add the given edge at the end of the list.
-
#set_default(dict) ⇒ Object
Set some default values for current elements.
Constructor Details
Instance Method Details
#push(e) ⇒ EdgeArray
Add the given edge at the end of the list
188 189 190 191 192 193 194 195 196 |
# File 'lib/graph.rb', line 188 def push(e) if (!e.is_a?(Hash) && !e.is_a?(Edge)) raise TypeError.new "#{e.inspect} is not an Hash nor an Edge!" end e = Edge.new(e) if (e.is_a?(Hash)) super(e.clone.update(@defaults)) end |
#set_default(dict) ⇒ Object
Note:
This method can be called multiple times.
Set some default values for current elements.
180 181 182 183 |
# File 'lib/graph.rb', line 180 def set_default(dict) @defaults.update(dict) self.map! { |e| e.update(@defaults) } end |