Class: Awshark::Ec2::Instance

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(instance) ⇒ Instance

Returns a new instance of Instance.



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/awshark/ec2/instance.rb', line 16

def initialize(instance)
  @id = instance.instance_id
  @type = instance.instance_type
  @state = instance.state.name
  @private_ip_address = instance.private_ip_address
  @public_ip_address = instance.public_ip_address
  @public_dns_name = instance.public_dns_name
  @vpc_id = instance.vpc_id
  @subnet_id = instance.subnet_id
  @tags = instance.tags
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/awshark/ec2/instance.rb', line 6

def id
  @id
end

#private_ip_addressObject (readonly)

Returns the value of attribute private_ip_address.



9
10
11
# File 'lib/awshark/ec2/instance.rb', line 9

def private_ip_address
  @private_ip_address
end

#public_dns_nameObject (readonly)

Returns the value of attribute public_dns_name.



11
12
13
# File 'lib/awshark/ec2/instance.rb', line 11

def public_dns_name
  @public_dns_name
end

#public_ip_addressObject (readonly)

Returns the value of attribute public_ip_address.



10
11
12
# File 'lib/awshark/ec2/instance.rb', line 10

def public_ip_address
  @public_ip_address
end

#stateObject (readonly)

Returns the value of attribute state.



8
9
10
# File 'lib/awshark/ec2/instance.rb', line 8

def state
  @state
end

#subnet_idObject (readonly)

Returns the value of attribute subnet_id.



13
14
15
# File 'lib/awshark/ec2/instance.rb', line 13

def subnet_id
  @subnet_id
end

#tagsObject (readonly)

Returns the value of attribute tags.



14
15
16
# File 'lib/awshark/ec2/instance.rb', line 14

def tags
  @tags
end

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/awshark/ec2/instance.rb', line 7

def type
  @type
end

#vpc_idObject (readonly)

Returns the value of attribute vpc_id.



12
13
14
# File 'lib/awshark/ec2/instance.rb', line 12

def vpc_id
  @vpc_id
end

Instance Method Details

#nameObject



28
29
30
31
32
# File 'lib/awshark/ec2/instance.rb', line 28

def name
  tag_value(tags, 'Name').split(' - ').last
rescue StandardError
  'null'
end