class Graph::Edge

An edge. This class is just a wrapper around a hash of attributes since before version 0.1.5 edges were simple hashes @since 0.1.6

Attributes

attrs[RW]

@return Edge’s attributes

Public Class Methods

new(attrs=nil) click to toggle source

Create a new edge @param attrs [Edge, Hash]

# File lib/graph.rb, line 98
def initialize(attrs=nil)
    @attrs = attrs.is_a?(Edge) ? attrs.attrs : attrs || {}
end

Public Instance Methods

==(other) click to toggle source

Compare two edges @param other [Edge] @return [Boolean]

# File lib/graph.rb, line 105
def ==(other)
    return false if !other.is_a?(Edge)

    @attrs == other.attrs
end
method_missing(method, *args, &block) click to toggle source
# File lib/graph.rb, line 118
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 edge, like the +Hash#update+ method. @param h [Hash] @return [Edge]

Calls superclass method
# File lib/graph.rb, line 114
def update(h)
    Edge.new super(h)
end