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.



15663
15664
15665
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15663

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



15661
15662
15663
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15661

def value
  @value
end

Class Method Details

.ALLObject



15683
15684
15685
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15683

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



15668
15669
15670
15671
15672
15673
15674
15675
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15668

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



15688
15689
15690
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15688

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



15678
15679
15680
15681
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15678

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



15693
15694
15695
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15693

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

Instance Method Details

#to_hashObject



15697
15698
15699
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15697

def to_hash
  value
end