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.



17873
17874
17875
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17873

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



17871
17872
17873
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17871

def value
  @value
end

Class Method Details

.ALLObject



17893
17894
17895
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17893

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



17878
17879
17880
17881
17882
17883
17884
17885
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17878

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



17888
17889
17890
17891
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17888

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.



17905
17906
17907
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17905

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



17899
17900
17901
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17899

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

Instance Method Details

#to_hashObject



17909
17910
17911
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17909

def to_hash
  value
end