class Spotdog::CLI

Public Instance Methods

send() click to toggle source
# File lib/spotdog/cli.rb, line 10
def send
  spot_price_history = Spotdog::EC2.spot_price_history(
    instance_types: options[:instance_types] ? options[:instance_types].split(",") : nil,
    max_results: options[:max_results],
    product_descriptions: options[:product_descriptions] ?
      convert_product_descriptions(options[:product_descriptions].split(",")) : nil,
    start_time: parse_start_time(options),
    end_time: parse_end_time(options),
  )
  Spotdog::Datadog.send_price_history(ENV["DATADOG_API_KEY"], spot_price_history)
end

Private Instance Methods

convert_product_descriptions(product_descriptions) click to toggle source
# File lib/spotdog/cli.rb, line 24
def convert_product_descriptions(product_descriptions)
  product_descriptions.map { |description| Spotdog::EC2::PRODUCT_DESCRIPTIONS[description.to_sym] }
end
current_time() click to toggle source
# File lib/spotdog/cli.rb, line 28
def current_time
  @current_time ||= Time.now
end
parse_end_time(options) click to toggle source
# File lib/spotdog/cli.rb, line 40
def parse_end_time(options)
  if options[:last_minutes]
    current_time
  else
    options[:end_time] ? Time.parse(options[:end_time]) : nil
  end
end
parse_start_time(options) click to toggle source
# File lib/spotdog/cli.rb, line 32
def parse_start_time(options)
  if options[:last_minutes]
    current_time - options[:last_minutes] * 60
  else
    options[:start_time] ? Time.parse(options[:start_time]) : nil
  end
end