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.



19691
19692
19693
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19691

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



19689
19690
19691
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19689

def value
  @value
end

Class Method Details

.ALLObject



19711
19712
19713
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19711

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



19696
19697
19698
19699
19700
19701
19702
19703
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19696

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



19706
19707
19708
19709
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19706

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.



19723
19724
19725
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19723

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’.



19717
19718
19719
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19717

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

Instance Method Details

#to_hashObject



19727
19728
19729
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19727

def to_hash
  value
end