Class: Azure::Images

Inherits:
Object
  • Object
show all
Defined in:
lib/azure/image.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ Images

Returns a new instance of Images.



21
22
23
# File 'lib/azure/image.rb', line 21

def initialize(connection)
  @connection=connection
end

Instance Method Details

#allObject



37
38
39
# File 'lib/azure/image.rb', line 37

def all
  self.load.values
end

#exists?(name) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/azure/image.rb', line 41

def exists?(name)
  self.all.key?(name)
end

#find(name) ⇒ Object



45
46
47
# File 'lib/azure/image.rb', line 45

def find(name)
  self.load[name]
end

#loadObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/azure/image.rb', line 24

def load
  @images ||= begin
    images = Hash.new
    response = @connection.query_azure('images')
    osimages = response.css('OSImage')
    osimages.each do |image|
      item = Image.new(image)
      images[item.name] = item
    end
    images
  end
end