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.



10524
10525
10526
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10524

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



10522
10523
10524
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10522

def value
  @value
end

Class Method Details

.ALLObject



10544
10545
10546
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10544

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



10529
10530
10531
10532
10533
10534
10535
10536
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10529

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



10539
10540
10541
10542
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10539

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.



10556
10557
10558
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10556

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



10550
10551
10552
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10550

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

Instance Method Details

#to_hashObject



10560
10561
10562
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10560

def to_hash
  value
end