Class: Biosphere::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/biosphere/node.rb

Defined Under Namespace

Classes: Attribute

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from = nil) ⇒ Node

Returns a new instance of Node.



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/biosphere/node.rb', line 32

def initialize(from = nil)
    if from && from.is_a?(String)
        blob = Marshal.load(from)
        if blob.class == Biosphere::Node
            raise "Tried to load old state format. Unfortunately we are not backwards compatible"
        end
        @data = blob
    elsif from
        @data = from
    else
        @data = Attribute.new
    end
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



31
32
33
# File 'lib/biosphere/node.rb', line 31

def data
  @data
end

Instance Method Details

#[](symbol, *args) ⇒ Object



66
67
68
# File 'lib/biosphere/node.rb', line 66

def [](symbol, *args)
    return @data[symbol]
end

#[]=(symbol, *args) ⇒ Object



62
63
64
# File 'lib/biosphere/node.rb', line 62

def []=(symbol, *args)
    @data[symbol] = args[0]
end

#deep_set(*args) ⇒ Object



58
59
60
# File 'lib/biosphere/node.rb', line 58

def deep_set(*args)
    @data.deep_set(*args)
end

#include?(symbol) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/biosphere/node.rb', line 54

def include?(symbol)
    @data.include?(symbol)
end

#merge!(obj) ⇒ Object



70
71
72
# File 'lib/biosphere/node.rb', line 70

def merge!(obj)
    @data.deep_merge!(obj)
end

#saveObject



74
75
76
# File 'lib/biosphere/node.rb', line 74

def save()
    return Marshal.dump(@data)
end

#valuesObject



78
79
80
# File 'lib/biosphere/node.rb', line 78

def values
    return @data.values
end