class Graph::EdgeArray
An array of Edge
objects
Public Class Methods
new(li)
click to toggle source
Create a new EdgeArray
from an existing Array
. @param li [Array<Edge, Hash>]
Calls superclass method
# File lib/graph.rb, line 169 def initialize(li) edges = li.map { |n| n.is_a?(Edge) ? n : Edge.new(n) } super(edges) @defaults = {} end
Public Instance Methods
push(e)
click to toggle source
Add the given edge at the end of the list @param e [Edge] @return [EdgeArray]
Calls superclass method
# 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)
click to toggle source
Set some default values for current elements. @note This method can be called multiple times. @example Set all edges’s ‘created-at’ value to ‘2012-05-03’
myEdgeList.set_default({'created-at'=>'2012-05-03'})
@param dict [Hash]
# File lib/graph.rb, line 180 def set_default(dict) @defaults.update(dict) self.map! { |e| e.update(@defaults) } end