Class: Io::Flow::V0::Models::RoundingType
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::RoundingType
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
- .ALL ⇒ Object
-
.apply(value) ⇒ Object
Returns the instance of RoundingType for this value, creating a new instance for an unknown value.
-
.from_string(value) ⇒ Object
Returns the instance of RoundingType for this value, or nil if not found.
-
.multiple ⇒ Object
Rounds a value to an amount that is the multiple of a value, e.g.
-
.pattern ⇒ Object
Rounds a value to an amount ending with a pattern, e.g.
Instance Method Summary collapse
-
#initialize(value) ⇒ RoundingType
constructor
A new instance of RoundingType.
- #to_hash ⇒ Object
Constructor Details
#initialize(value) ⇒ RoundingType
Returns a new instance of RoundingType.
20201 20202 20203 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20201 def initialize(value) @value = HttpClient::Preconditions.assert_class('value', value, String) end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
20199 20200 20201 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20199 def value @value end |
Class Method Details
.ALL ⇒ Object
20221 20222 20223 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20221 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
20206 20207 20208 20209 20210 20211 20212 20213 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20206 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
20216 20217 20218 20219 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20216 def RoundingType.from_string(value) HttpClient::Preconditions.assert_class('value', value, String) RoundingType.ALL.find { |v| v.value == value } end |
.multiple ⇒ Object
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.
20233 20234 20235 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20233 def RoundingType.multiple @@_multiple ||= RoundingType.new('multiple') end |
.pattern ⇒ Object
Rounds a value to an amount ending with a pattern, e.g. an amount ending in ‘.99’.
20227 20228 20229 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20227 def RoundingType.pattern @@_pattern ||= RoundingType.new('pattern') end |
Instance Method Details
#to_hash ⇒ Object
20237 20238 20239 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20237 def to_hash value end |