Class: Graph::Node
- Inherits:
-
Object
- Object
- Graph::Node
- Defined in:
- lib/graph.rb
Overview
A node. This class is just a wrapper around a hash of attributes since in version <= 0.1.5 nodes were simple hashes
Instance Attribute Summary collapse
-
#attrs ⇒ Object
Returns the value of attribute attrs.
Instance Method Summary collapse
-
#==(other) ⇒ Object
compare two nodes.
-
#initialize(attrs = nil) ⇒ Node
constructor
A new instance of Node.
- #method_missing(method, *args, &block) ⇒ Object
Constructor Details
#initialize(attrs = nil) ⇒ Node
Returns a new instance of Node.
56 57 58 |
# File 'lib/graph.rb', line 56 def initialize(attrs=nil) @attrs = attrs || {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
68 69 70 |
# File 'lib/graph.rb', line 68 def method_missing(method, *args, &block) @attrs.send(method, *args, &block) end |
Instance Attribute Details
#attrs ⇒ Object
Returns the value of attribute attrs.
54 55 56 |
# File 'lib/graph.rb', line 54 def attrs @attrs end |
Instance Method Details
#==(other) ⇒ Object
compare two nodes
62 63 64 65 66 |
# File 'lib/graph.rb', line 62 def ==(other) return false if !other.is_a?(Node) @attrs == other.attrs end |