Class: Pec::Configure

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/pec/configure.rb,
lib/pec/configure/host.rb,
lib/pec/configure/sample.rb,
lib/pec/configure/ethernet.rb,
lib/pec/configure/user_data.rb

Defined Under Namespace

Classes: Ethernet, Host, Sample, UserData

Instance Method Summary collapse

Constructor Details

#initialize(file_name) ⇒ Configure

Returns a new instance of Configure.



6
7
8
9
10
11
12
13
14
# File 'lib/pec/configure.rb', line 6

def initialize(file_name)
  YAML.load_file(file_name).to_hash.each do |config|
    host = Pec::Configure::Host.load(config)
    @configure ||= []
    @configure << host if host
  end
  rescue Psych::SyntaxError,NoMethodError => e
    raise(Pec::Errors::Configure, e)
end

Instance Method Details

#eachObject



20
21
22
23
24
# File 'lib/pec/configure.rb', line 20

def each
  @configure.each do |config|
    yield config
  end
end

#filter_by_host(host_name) ⇒ Object



16
17
18
# File 'lib/pec/configure.rb', line 16

def filter_by_host(host_name)
  @configure.select {|h| host_name.nil? || host_name == h.name}
end