Class: Io::Flow::V0::Models::RoundingType

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

Returns a new instance of RoundingType.



11044
11045
11046
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11044

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



11042
11043
11044
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11042

def value
  @value
end

Class Method Details

.ALLObject



11064
11065
11066
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11064

def RoundingType.ALL
  @@all ||= [RoundingType.pattern, RoundingType.multiple]
end

.apply(value) ⇒ Object

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



11049
11050
11051
11052
11053
11054
11055
11056
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11049

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

.from_string(value) ⇒ Object

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



11059
11060
11061
11062
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11059

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

.multipleObject

Rounds a value to an amount that is the multiple of a value, e.g. rounding to the nearest 5 would ensure that the resulting number ends in either 0 or 5.



11076
11077
11078
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11076

def RoundingType.multiple
  @@_multiple ||= RoundingType.new('multiple')
end

.patternObject

Rounds a value to an amount ending with a pattern, e.g. an amount ending in ‘.99’.



11070
11071
11072
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11070

def RoundingType.pattern
  @@_pattern ||= RoundingType.new('pattern')
end

Instance Method Details

#to_hashObject



11080
11081
11082
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11080

def to_hash
  value
end