Sha256: 139875d4161e77dca042f9df6530c0e10708ad8361b369d03dfe1fd77e64ae37

Contents?: true

Size: 1021 Bytes

Versions: 9

Compression:

Stored size: 1021 Bytes

Contents

module Brightbox
  class Image < Api
    
    def to_row
      o = fog_model.attributes
      o[:id] = fog_model.id
      if status == "available"
        o[:status] = (public ? 'public' : 'private')
      else
        o[:status] = status
      end
      o[:arch] = arch
      o[:name] = name.to_s + " (#{arch})"
      o[:owner] = owner_id
      if official
        o[:type] = "official"
        o[:owner] = "brightbox"
      else
        o[:type] = source_type
      end
      o[:created_at] = created_at
      o[:created_on] = created_at.to_s.split('T').first
      o[:description] = description if description
      o[:size] = virtual_size
      o
    end

    def self.register(options = {})
      image = conn.create_image(options)
      find image['id']
    end

    def public?
      public
    end

    def self.all
      conn.images
    end

    def self.get(id)
      conn.images.get(id)
    end

    def self.default_field_order
      [:id, :owner, :type, :created_on, :status, :size, :name]
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
bbcloud-0.13.0 lib/bbcloud/images.rb
bbcloud-0.12.0 lib/bbcloud/images.rb
bbcloud-0.11.2 lib/bbcloud/images.rb
bbcloud-0.11.1 lib/bbcloud/images.rb
bbcloud-0.11.0 lib/bbcloud/images.rb
bbcloud-0.10.1 lib/bbcloud/images.rb
bbcloud-0.9.2 lib/bbcloud/images.rb
bbcloud-0.9.1 lib/bbcloud/images.rb
bbcloud-0.9 lib/bbcloud/images.rb