Class: Ec2list::Instance

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ec2) ⇒ Instance

Returns a new instance of Instance.



69
70
71
72
73
74
75
76
77
78
# File 'lib/ec2list.rb', line 69

def initialize(ec2)
  @id = ec2.instance_id
  @type = ec2.instance_type
  @status = ec2.state.name
  @since = since_about(Time.now - ec2.launch_time)
  @tags = ec2.tags || []
  @fqdn = ec2.public_dns_name
  @ip_addr = ec2.public_ip_address
  @private_addr = ec2.private_ip_address
end

Instance Attribute Details

#fqdnObject

Returns the value of attribute fqdn.



67
68
69
# File 'lib/ec2list.rb', line 67

def fqdn
  @fqdn
end

#idObject

Returns the value of attribute id.



67
68
69
# File 'lib/ec2list.rb', line 67

def id
  @id
end

#ip_addrObject

Returns the value of attribute ip_addr.



67
68
69
# File 'lib/ec2list.rb', line 67

def ip_addr
  @ip_addr
end

#private_addrObject

Returns the value of attribute private_addr.



67
68
69
# File 'lib/ec2list.rb', line 67

def private_addr
  @private_addr
end

#sinceObject

Returns the value of attribute since.



67
68
69
# File 'lib/ec2list.rb', line 67

def since
  @since
end

#statusObject

Returns the value of attribute status.



67
68
69
# File 'lib/ec2list.rb', line 67

def status
  @status
end

#tagsObject

Returns the value of attribute tags.



67
68
69
# File 'lib/ec2list.rb', line 67

def tags
  @tags
end

#typeObject

Returns the value of attribute type.



67
68
69
# File 'lib/ec2list.rb', line 67

def type
  @type
end

Instance Method Details

#cont?(tag) ⇒ Boolean

Returns:

  • (Boolean)


93
94
95
# File 'lib/ec2list.rb', line 93

def cont?(tag)
  name && name.include?(tag)
end

#nameObject



80
81
82
83
84
85
86
87
# File 'lib/ec2list.rb', line 80

def name
  name_tag = tags.find { |tag| tag.key == 'Name' }
  if name_tag
    name_tag.value.gsub(' ', '_')
  else
    nil
  end
end

#tagObject



89
90
91
# File 'lib/ec2list.rb', line 89

def tag
  name
end