all()
click to toggle source
def all
load(connection.list_public_images_detailed.body['images'])
end
destroy(id)
click to toggle source
def destroy(id)
image = self.find_by_id(id)
image.destroy
end
details()
click to toggle source
def details
load(connection.list_public_images_detailed.body['images'])
end
find_attribute(attribute,value)
click to toggle source
def find_attribute(attribute,value)
attribute = attribute.to_s.gsub("find_by_", "")
load(connection.list_public_images_detailed(attribute , value).body['images'])
end
find_by_id(id)
click to toggle source
def find_by_id(id)
self.find {|image| image.id == id}
end
find_by_size_max(size)
click to toggle source
def find_by_size_max(size)
find_attribute(__method__, size)
end
find_by_size_min(size)
click to toggle source
def find_by_size_min(size)
find_attribute(__method__, size)
end
method_missing(method_sym, *arguments, &block)
click to toggle source
def method_missing(method_sym, *arguments, &block)
if method_sym.to_s =~ %r^find_by_(.*)$/
load(connection.list_public_images_detailed($1 ,arguments.first).body['images'])
else
super
end
end
private()
click to toggle source
def private
images = load(connection.list_public_images_detailed.body['images'])
images.delete_if{|image| image.is_public}
end
public()
click to toggle source
def public
images = load(connection.list_public_images_detailed.body['images'])
images.delete_if{|image| image.is_public == false}
end