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.



13199
13200
13201
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13199

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



13197
13198
13199
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13197

def value
  @value
end

Class Method Details

.ALLObject



13219
13220
13221
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13219

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



13204
13205
13206
13207
13208
13209
13210
13211
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13204

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



13229
13230
13231
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13229

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



13214
13215
13216
13217
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13214

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

.rangeObject

Tightest range



13224
13225
13226
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13224

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

.toObject

Lowest maximum of the ranges



13234
13235
13236
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13234

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

Instance Method Details

#to_hashObject



13238
13239
13240
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13238

def to_hash
  value
end