Class: Yao::Resources::Image

Inherits:
Base
  • Object
show all
Extended by:
MetadataAvailable
Defined in:
lib/yao/resources/image.rb

Instance Attribute Summary

Attributes included from RestfullyAccessible

#service

Instance Method Summary collapse

Methods included from MetadataAvailable

create_metadata, delete_metadata, get_metadata, list_metadata, set_metadata, update_metadata

Methods inherited from Base

#[], #[]=, #created, friendly_attributes, #id, #initialize, map_attribute_to_attribute, map_attribute_to_resource, map_attribute_to_resources, #to_hash, #updated

Methods included from RestfullyAccessible

#admin=, #api_version, #api_version=, #as_member, #client, #create, #destroy, extended, #find_by_name, #get, #get!, #list, #resources_path, #resources_path=, #return_single_on_querying, #return_single_on_querying=, #update

Constructor Details

This class inherits a constructor from Yao::Resources::Base

Instance Method Details

#size(unit = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/yao/resources/image.rb', line 8

def size(unit=nil)
  size = self["OS-EXT-IMG-SIZE:size"]
  case unit
  when 'K'
    size / 1024.0
  when 'M'
    size / 1024.0 / 1024.0
  when 'G'
    size / 1024.0 / 1024.0 / 1024.0
  else
    size
  end
end