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.
11036 11037 11038 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11036 def initialize(value) @value = HttpClient::Preconditions.assert_class('value', value, String) end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
11034 11035 11036 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11034 def value @value end |
Class Method Details
.ALL ⇒ Object
11056 11057 11058 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11056 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
11041 11042 11043 11044 11045 11046 11047 11048 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11041 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
11051 11052 11053 11054 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11051 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.
11068 11069 11070 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11068 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’.
11062 11063 11064 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11062 def RoundingType.pattern @@_pattern ||= RoundingType.new('pattern') end |
Instance Method Details
#to_hash ⇒ Object
11072 11073 11074 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11072 def to_hash value end |