Class: Sambot::Rackspace::Images

Inherits:
Object
  • Object
show all
Defined in:
lib/sambot/rackspace/images.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Images

Returns a new instance of Images.



7
8
9
# File 'lib/sambot/rackspace/images.rb', line 7

def initialize(client)
  @client = client
end

Instance Method Details

#allObject



11
12
13
# File 'lib/sambot/rackspace/images.rb', line 11

def all
  @client.images.all.map { |image| { name: image.name, value: image.id } }.compact
end

#availableObject



15
16
17
# File 'lib/sambot/rackspace/images.rb', line 15

def available
  all.find_all { |x| x[:name] =~ /AS/ }
end

#find_platform_by_image_id(id) ⇒ Object



19
20
21
22
23
# File 'lib/sambot/rackspace/images.rb', line 19

def find_platform_by_image_id(id)
  available_images = all
  image = available_images.find { |x| x[:value] == id }
  image[:name].match?(/Linux/) ? 'L' : 'W'
end