Class: Pec::Configure
- Inherits:
-
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
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/pec/configure.rb', line 6
def initialize(file_name)
if file_name.is_a?(Hash)
hash = file_name
else
hash = YAML.load_file(file_name).to_hash
end
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
26
27
28
29
30
|
# File 'lib/pec/configure.rb', line 26
def each
@configure.each do |config|
yield config
end
end
|
#filter_by_host(host_name) ⇒ Object
22
23
24
|
# File 'lib/pec/configure.rb', line 22
def filter_by_host(host_name)
@configure.select {|h| host_name.nil? || host_name == h.name}
end
|