class Graph::Node
A node. This class is just a wrapper around a hash of attributes. Before 0.1.6, nodes were simple hashs @since 0.1.6
Attributes
attrs[RW]
@return Node’s attributes
Public Class Methods
new(attrs=nil)
click to toggle source
Create a new Node
@param attrs [Node, Hash]
# File lib/graph.rb, line 59 def initialize(attrs=nil) @attrs = attrs.is_a?(Node) ? attrs.attrs : attrs || {} end
Public Instance Methods
==(other)
click to toggle source
compare two nodes @param other [Node] @return [Boolean]
# File lib/graph.rb, line 66 def ==(other) return false if !other.is_a?(Node) @attrs == other.attrs end
method_missing(method, *args, &block)
click to toggle source
# File lib/graph.rb, line 79 def method_missing(method, *args, &block) return @attrs[method.to_sym] if @attrs.has_key? method.to_sym return @attrs[method.to_s] if @attrs.has_key? method.to_s @attrs.send(method, *args, &block) end
update(h)
click to toggle source
Update the current node, like the +Hash#update+ method. @param h [Hash] @return [Node]
Calls superclass method
# File lib/graph.rb, line 75 def update(h) Node.new super(h) end