Class: Graph::Edge
- Inherits:
-
Object
- Object
- Graph::Edge
- Defined in:
- lib/graph.rb
Overview
An edge. This class is just a wrapper around a hash of attributes since before version 0.1.5 edges were simple hashes
Instance Attribute Summary collapse
-
#attrs ⇒ Object
Edge’s attributes.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Compare two edges.
-
#initialize(attrs = nil) ⇒ Edge
constructor
Create a new edge.
- #method_missing(method, *args, &block) ⇒ Object
-
#update(h) ⇒ Edge
Update the current edge, like the Hash#update method.
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
118 119 120 121 122 123 |
# 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 |
Instance Attribute Details
#attrs ⇒ Object
Returns Edge’s attributes.
94 95 96 |
# File 'lib/graph.rb', line 94 def attrs @attrs end |
Instance Method Details
#==(other) ⇒ Boolean
Compare two edges
105 106 107 108 109 |
# File 'lib/graph.rb', line 105 def ==(other) return false if !other.is_a?(Edge) @attrs == other.attrs end |