Class: DigitalOceanInventory::Host

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, droplet, config) ⇒ Host

Returns a new instance of Host.



14
15
16
17
18
# File 'lib/digital_ocean_inventory/host.rb', line 14

def initialize(name, droplet, config)
  @name    = name
  @droplet = droplet
  @config  = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'lib/digital_ocean_inventory/host.rb', line 5

def config
  @config
end

#dropletObject (readonly)

Returns the value of attribute droplet.



5
6
7
# File 'lib/digital_ocean_inventory/host.rb', line 5

def droplet
  @droplet
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/digital_ocean_inventory/host.rb', line 5

def name
  @name
end

Class Method Details

.build(opts = {}) ⇒ Object



7
8
9
10
11
12
# File 'lib/digital_ocean_inventory/host.rb', line 7

def self.build(opts = {})
  config  = opts[:config]
  droplet = opts[:droplet]

  new droplet.name, droplet, config
end

Instance Method Details

#varsObject



20
21
22
23
24
25
# File 'lib/digital_ocean_inventory/host.rb', line 20

def vars
  return @_vars if defined? @_vars

  @_vars = host_vars.to_h
  @_vars
end