Class: EC2Instance

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

Instance Method Summary collapse

Constructor Details

#initialize(h, caller = nil) ⇒ EC2Instance

Returns a new instance of EC2Instance.



10
11
12
13
14
15
# File 'lib/instant_ec2.rb', line 10

def initialize(h, caller=nil)

  @c = caller
  super().merge!(h)

end

Instance Method Details

#start(duration: nil) ⇒ Object



17
18
19
20
21
22
# File 'lib/instant_ec2.rb', line 17

def start(duration: nil)

  @c.start_instance self[:instance_id]       
  Thread.new{ sleep duration.to_i * 60; self.stop} if duration

end

#stopObject



24
25
26
27
28
# File 'lib/instant_ec2.rb', line 24

def stop()

  @c.stop_instance self[:instance_id]

end