Class: Protocore::Host
- Inherits:
-
Object
- Object
- Protocore::Host
- Defined in:
- lib/protocore.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#structure ⇒ Object
readonly
Returns the value of attribute structure.
Instance Method Summary collapse
-
#initialize(structure) ⇒ Host
constructor
A new instance of Host.
- #to_yaml ⇒ Object
Constructor Details
#initialize(structure) ⇒ Host
Returns a new instance of Host.
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
#name ⇒ Object (readonly)
Returns the value of attribute name.
25 26 27 |
# File 'lib/protocore.rb', line 25 def name @name end |
#structure ⇒ Object (readonly)
Returns the value of attribute structure.
24 25 26 |
# File 'lib/protocore.rb', line 24 def structure @structure end |
Instance Method Details
#to_yaml ⇒ Object
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 |