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.
18736 18737 18738 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18736 def initialize(value) @value = HttpClient::Preconditions.assert_class('value', value, String) end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
18734 18735 18736 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18734 def value @value end |
Class Method Details
.ALL ⇒ Object
18756 18757 18758 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18756 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
18741 18742 18743 18744 18745 18746 18747 18748 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18741 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
18751 18752 18753 18754 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18751 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.
18768 18769 18770 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18768 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'.
18762 18763 18764 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18762 def RoundingType.pattern @@_pattern ||= RoundingType.new('pattern') end |
Instance Method Details
#to_hash ⇒ Object
18772 18773 18774 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18772 def to_hash value end |