Class: Protocore::Host

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(structure) ⇒ Host

Returns a new instance of Host.

Raises:

  • (ArgumentError)


27
28
29
30
31
# File 'lib/protocore.rb', line 27

def initialize(structure)
  raise ArgumentError, "structure cannot be nil" unless structure
  @structure = structure
  @name = structure["hostname"]
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



25
26
27
# File 'lib/protocore.rb', line 25

def name
  @name
end

#structureObject (readonly)

Returns the value of attribute structure.



24
25
26
# File 'lib/protocore.rb', line 24

def structure
  @structure
end

Instance Method Details

#to_yamlObject



33
34
35
36
37
38
# File 'lib/protocore.rb', line 33

def to_yaml
  @yaml ||= structure.to_yaml.
    gsub(/(?<=\:\s)\"(.*)\"(?=\n)/i, '\1').
    gsub(/(?<=\:\s)\'(off)\'(?=\n)/, '\1').
    gsub(/^---/,"#cloud-config")
end