class EC2Instance

Public Class Methods

new(h, caller=nil) click to toggle source
Calls superclass method
# File lib/instant_ec2.rb, line 10
def initialize(h, caller=nil)

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

end

Public Instance Methods

start(duration: nil) click to toggle source
# File lib/instant_ec2.rb, line 17
def start(duration: nil)

  @c.start_instance self[:instance_id]
  
  if duration then
    
    seconds = duration.to_i * 60
    
    if @c.async then
      Thread.new{ sleep seconds; self.stop} 
    else
      sleep seconds
      self.stop
    end
  end

end
stop() click to toggle source
# File lib/instant_ec2.rb, line 35
def stop()

  @c.stop_instance self[:instance_id]

end