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.
6 7 8 9 10 11 12 13 |
# File 'lib/biosphere/node.rb', line 6 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.
5 6 7 |
# File 'lib/biosphere/node.rb', line 5 def data @data end |
Instance Method Details
#[](symbol, *args) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/biosphere/node.rb', line 23 def [](symbol, *args) if !@data[symbol] @data[symbol] = Node.new end return @data[symbol] end |
#[]=(symbol, *args) ⇒ Object
19 20 21 |
# File 'lib/biosphere/node.rb', line 19 def []=(symbol, *args) @data[symbol] = args[0] end |
#include?(symbol) ⇒ Boolean
15 16 17 |
# File 'lib/biosphere/node.rb', line 15 def include?(symbol) @data.include?(symbol) end |
#save ⇒ Object
30 31 32 |
# File 'lib/biosphere/node.rb', line 30 def save() return Marshal.dump(self) end |