module UbuntuAmis

Constants

URL
VERSION

Public Class Methods

fix_string(data) click to toggle source
# File lib/ubuntu_amis.rb, line 23
def self.fix_string(data)
  data.reverse.sub(',','').reverse
end
fix_table(table) click to toggle source
# File lib/ubuntu_amis.rb, line 27
def self.fix_table(table)
  table.each_with_index{|row,index|
    table[index][6] = row[6][/(ami-[\da-f]{8})/,1]
  }
  table
end
get(uri) click to toggle source
# File lib/ubuntu_amis.rb, line 19
def self.get(uri)
  Net::HTTP.get_response(uri).body
end
parse(json) click to toggle source
# File lib/ubuntu_amis.rb, line 34
def self.parse(json)
  YAML.load(json)
end
table() click to toggle source
# File lib/ubuntu_amis.rb, line 9
def self.table
  fix_table(parse(fix_string(get(uri)))["aaData"])
end
uri() click to toggle source
# File lib/ubuntu_amis.rb, line 13
def self.uri
  URI(URL).tap { |uri|
    uri.query = Time.now.to_i.to_s
  }
end