Class: Io::Flow::V0::Models::TierStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ TierStrategy

Returns a new instance of TierStrategy.



9263
9264
9265
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9263

def initialize(value)
  @value = HttpClient::Preconditions.assert_class('value', value, String)
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



9261
9262
9263
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9261

def value
  @value
end

Class Method Details

.ALLObject



9283
9284
9285
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9283

def TierStrategy.ALL
  @@all ||= [TierStrategy.fastest, TierStrategy.lowest_cost]
end

.apply(value) ⇒ Object

Returns the instance of TierStrategy for this value, creating a new instance for an unknown value



9268
9269
9270
9271
9272
9273
9274
9275
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9268

def TierStrategy.apply(value)
  if value.instance_of?(TierStrategy)
    value
  else
    HttpClient::Preconditions.assert_class_or_nil('value', value, String)
    value.nil? ? nil : (from_string(value) || TierStrategy.new(value))
  end
end

.fastestObject

Optimize for fastest first, then cheapest



9288
9289
9290
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9288

def TierStrategy.fastest
  @@_fastest ||= TierStrategy.new('fastest')
end

.from_string(value) ⇒ Object

Returns the instance of TierStrategy for this value, or nil if not found



9278
9279
9280
9281
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9278

def TierStrategy.from_string(value)
  HttpClient::Preconditions.assert_class('value', value, String)
  TierStrategy.ALL.find { |v| v.value == value }
end

.lowest_costObject

Optimize for lowest cost first, then fastest



9293
9294
9295
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9293

def TierStrategy.lowest_cost
  @@_lowest_cost ||= TierStrategy.new('lowest_cost')
end

Instance Method Details

#to_hashObject



9297
9298
9299
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9297

def to_hash
  value
end