Class: OpsWorker::Instance

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, hostname, status, instance_type, elastic_ip, availability_zone, app, layers) ⇒ Instance

Returns a new instance of Instance.



5
6
7
8
9
10
11
12
13
14
# File 'lib/ops_worker/instance.rb', line 5

def initialize(id, hostname, status, instance_type, elastic_ip, availability_zone, app, layers)
  @id = id
  @hostname = hostname
  @status = status
  @instance_type = instance_type
  @elastic_ip = elastic_ip
  @availability_zone = availability_zone
  @app = app
  @layers = layers
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



3
4
5
# File 'lib/ops_worker/instance.rb', line 3

def app
  @app
end

#availability_zoneObject (readonly)

Returns the value of attribute availability_zone.



3
4
5
# File 'lib/ops_worker/instance.rb', line 3

def availability_zone
  @availability_zone
end

#elastic_ipObject (readonly)

Returns the value of attribute elastic_ip.



3
4
5
# File 'lib/ops_worker/instance.rb', line 3

def elastic_ip
  @elastic_ip
end

#hostnameObject (readonly)

Returns the value of attribute hostname.



3
4
5
# File 'lib/ops_worker/instance.rb', line 3

def hostname
  @hostname
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/ops_worker/instance.rb', line 3

def id
  @id
end

#instance_typeObject (readonly)

Returns the value of attribute instance_type.



3
4
5
# File 'lib/ops_worker/instance.rb', line 3

def instance_type
  @instance_type
end

#layersObject (readonly)

Returns the value of attribute layers.



3
4
5
# File 'lib/ops_worker/instance.rb', line 3

def layers
  @layers
end

#statusObject (readonly)

Returns the value of attribute status.



3
4
5
# File 'lib/ops_worker/instance.rb', line 3

def status
  @status
end

Instance Method Details

#online?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/ops_worker/instance.rb', line 20

def online?
  @status == "online"
end

#stopped?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/ops_worker/instance.rb', line 16

def stopped?
  @status == "stopped"
end

#to_sObject



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

def to_s
  "#<OpsWorker::Instance #{@id}, host: #{@hostname}, status: #{@status}, type: #{@instance_type}, layers: #{@layers.map(&:name)}>"
end