Class: Biosphere::Node
- Inherits:
-
Object
- Object
- Biosphere::Node
- Defined in:
- lib/biosphere/node.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #[](symbol, *args) ⇒ Object
- #[]=(symbol, *args) ⇒ Object
- #include?(symbol) ⇒ Boolean
-
#initialize(from_string = nil) ⇒ Node
constructor
A new instance of Node.
- #save ⇒ Object
Constructor Details
#initialize(from_string = nil) ⇒ Node
Returns a new instance of Node.
7 8 9 10 11 12 13 14 |
# File 'lib/biosphere/node.rb', line 7 def initialize(from_string = nil) if from_string blob = Marshal.load(from_string) @data = blob.data else @data = {} end end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/biosphere/node.rb', line 6 def data @data end |
Instance Method Details
#[](symbol, *args) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/biosphere/node.rb', line 24 def [](symbol, *args) if !@data[symbol] @data[symbol] = Node.new end return @data[symbol] end |
#[]=(symbol, *args) ⇒ Object
20 21 22 |
# File 'lib/biosphere/node.rb', line 20 def []=(symbol, *args) @data[symbol] = args[0] end |
#include?(symbol) ⇒ Boolean
16 17 18 |
# File 'lib/biosphere/node.rb', line 16 def include?(symbol) @data.include?(symbol) end |
#save ⇒ Object
31 32 33 |
# File 'lib/biosphere/node.rb', line 31 def save() return Marshal.dump(self) end |