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.



10703
10704
10705
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10703

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



10701
10702
10703
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10701

def value
  @value
end

Class Method Details

.ALLObject



10723
10724
10725
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10723

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



10708
10709
10710
10711
10712
10713
10714
10715
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10708

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



10728
10729
10730
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10728

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



10718
10719
10720
10721
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10718

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



10733
10734
10735
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10733

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

Instance Method Details

#to_hashObject



10737
10738
10739
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10737

def to_hash
  value
end