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.



18785
18786
18787
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18785

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



18783
18784
18785
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18783

def value
  @value
end

Class Method Details

.ALLObject



18805
18806
18807
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18805

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



18790
18791
18792
18793
18794
18795
18796
18797
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18790

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



18810
18811
18812
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18810

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



18800
18801
18802
18803
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18800

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



18815
18816
18817
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18815

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

Instance Method Details

#to_hashObject



18819
18820
18821
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18819

def to_hash
  value
end