Class: Onceover::Node

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

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Node

Returns a new instance of Node.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/onceover/node.rb', line 13

def initialize(name)
  @name = name
  @beaker_node = nil

  # If we can't find the factset it will fail, so just catch that error and ignore it
  begin
    facts_file_index = Onceover::Controlrepo.facts_files.index {|facts_file|
      File.basename(facts_file, '.json') == name
    }
    @fact_set = Onceover::Controlrepo.facts[facts_file_index]
    @trusted_set = Onceover::Controlrepo.trusted_facts[facts_file_index]
  rescue TypeError
    @fact_set = nil
    @trusted_set = nil
  end

  @@all << self

end

Instance Attribute Details

#beaker_nodeObject

Returns the value of attribute beaker_node.



9
10
11
# File 'lib/onceover/node.rb', line 9

def beaker_node
  @beaker_node
end

#fact_setObject

Returns the value of attribute fact_set.



10
11
12
# File 'lib/onceover/node.rb', line 10

def fact_set
  @fact_set
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#trusted_setObject

Returns the value of attribute trusted_set.



11
12
13
# File 'lib/onceover/node.rb', line 11

def trusted_set
  @trusted_set
end

Class Method Details

.allObject



47
48
49
# File 'lib/onceover/node.rb', line 47

def self.all
  @@all
end

.find(node_name) ⇒ Object



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

def self.find(node_name)
  @@all.each do |node|
    if node_name.is_a?(Onceover::Node)
      if node = node_name
        return node
      end
    elsif node.name == node_name
      return node
    end
  end
  logger.warn "Node #{node_name} not found"
  nil
end