Class: Motoko::Node

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

Direct Known Subclasses

Choria

Defined Under Namespace

Classes: Choria

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identity, facts) ⇒ Node

Returns a new instance of Node.



7
8
9
10
# File 'lib/motoko/node.rb', line 7

def initialize(identity, facts)
  @identity = identity
  @facts    = facts
end

Instance Attribute Details

#identityObject (readonly)

Returns the value of attribute identity.



5
6
7
# File 'lib/motoko/node.rb', line 5

def identity
  @identity
end

Instance Method Details

#fact(name) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/motoko/node.rb', line 12

def fact(name)
  result = @facts
  components = name.to_s.split('.')
  while (component = components.shift)
    case result
    when Hash
      result = result[component]
    when Array
      result = result[Integer(component)]
    when NilClass
      return nil
    end
  end
  result
end