Class: AWS::EC2::Instance

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(init_hash = {}) ⇒ Instance

Returns a new instance of Instance.



8
9
10
11
12
# File 'lib/instance.rb', line 8

def initialize(init_hash = {})
  init_hash.each do |k, v|
    self.send(k.to_s + "=", v) unless !self.respond_to?(k.to_s + "=")
  end
end

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



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

def connection
  @connection
end

#dnsObject

Returns the value of attribute dns.



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

def dns
  @dns
end

#instance_idObject

Returns the value of attribute instance_id.



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

def instance_id
  @instance_id
end

#launch_timeObject

Returns the value of attribute launch_time.



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

def launch_time
  @launch_time
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

#tagsObject

Returns the value of attribute tags.



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

def tags
  @tags
end

Instance Method Details

#match?(tag) ⇒ Boolean

Returns:

  • (Boolean)


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

def match?(tag)
  self.tags.detect {|h| h.detect { |k, v| v.to_s.match /#{tag}/ } }
end

#self_destructObject

If connection available, terminate self.



21
22
23
24
25
# File 'lib/instance.rb', line 21

def self_destruct
  raise "No Connection Associated With This Instance." unless !@connection.nil?
  @connection.terminate_instances(:instance_id => self.instance_id)
  # Have a Nice Day.
end