Class: Io::Flow::V0::Models::Strategy

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) ⇒ Strategy

Returns a new instance of Strategy.



6075
6076
6077
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6075

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



6073
6074
6075
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6073

def value
  @value
end

Class Method Details

.ALLObject



6095
6096
6097
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6095

def Strategy.ALL
  @@all ||= [Strategy.range, Strategy.from, Strategy.to]
end

.apply(value) ⇒ Object

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



6080
6081
6082
6083
6084
6085
6086
6087
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6080

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

.fromObject

Lowest minimum of the ranges



6105
6106
6107
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6105

def Strategy.from
  @@_from ||= Strategy.new('from')
end

.from_string(value) ⇒ Object

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



6090
6091
6092
6093
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6090

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

.rangeObject

Tightest range



6100
6101
6102
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6100

def Strategy.range
  @@_range ||= Strategy.new('range')
end

.toObject

Lowest maximum of the ranges



6110
6111
6112
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6110

def Strategy.to
  @@_to ||= Strategy.new('to')
end

Instance Method Details

#to_hashObject



6114
6115
6116
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6114

def to_hash
  value
end