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.



10418
10419
10420
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10418

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



10416
10417
10418
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10416

def value
  @value
end

Class Method Details

.ALLObject



10438
10439
10440
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10438

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



10423
10424
10425
10426
10427
10428
10429
10430
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10423

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



10443
10444
10445
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10443

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



10433
10434
10435
10436
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10433

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



10448
10449
10450
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10448

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

Instance Method Details

#to_hashObject



10452
10453
10454
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10452

def to_hash
  value
end