Sha256: 1f22a9fb2426db6d47170cf6c7150d9342be8f12b9e81a01d7b3b1452d013dad

Contents?: true

Size: 766 Bytes

Versions: 7

Compression:

Stored size: 766 Bytes

Contents

require 'fog/core/collection'
require 'fog/compute/models/linode/flavor'

module Fog
  module Compute
    class Linode
      class Flavors < Fog::Collection
        model Fog::Compute::Linode::Flavor

        def all
          load flavors
        end

        def get(id)
          new flavors(id).first
        rescue Fog::Linode::Compute::NotFound
          nil
        end

        private
        def flavors(id=nil)
          connection.avail_linodeplans(id).body['DATA'].map { |flavor| map_flavor flavor }
        end
        
        def map_flavor(flavor)
          flavor = flavor.each_with_object({}) { |(k, v), h| h[k.downcase.to_sym] = v  }
          flavor.merge! :id => flavor[:planid], :name => flavor[:label]
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
brightbox-cli-0.13.1 lib/brightbox-cli/vendor/fog/lib/fog/compute/models/linode/flavors.rb
brightbox-cli-0.13.0 lib/brightbox-cli/vendor/fog/lib/fog/compute/models/linode/flavors.rb
fog-0.11.0 lib/fog/compute/models/linode/flavors.rb
fog-0.10.0 lib/fog/compute/models/linode/flavors.rb
fog4encbs-0.9.0.1 lib/fog/compute/models/linode/flavors.rb
fog4encbs-0.9.0 lib/fog/compute/models/linode/flavors.rb
fog-0.9.0 lib/fog/compute/models/linode/flavors.rb