Class: Io::Flow::V0::Models::CurrencyLabelFormatter
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::CurrencyLabelFormatter
- 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 CurrencyLabelFormatter for this value, creating a new instance for an unknown value.
-
.from_string(value) ⇒ Object
Returns the instance of CurrencyLabelFormatter for this value, or nil if not found.
-
.strip_trailing_zeros ⇒ Object
If a price ends in ‘.00’ or ‘,00’, we remove the cents and just display the price as a whole number.
Instance Method Summary collapse
-
#initialize(value) ⇒ CurrencyLabelFormatter
constructor
A new instance of CurrencyLabelFormatter.
- #to_hash ⇒ Object
Constructor Details
#initialize(value) ⇒ CurrencyLabelFormatter
Returns a new instance of CurrencyLabelFormatter.
11004 11005 11006 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11004 def initialize(value) @value = HttpClient::Preconditions.assert_class('value', value, String) end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
11002 11003 11004 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11002 def value @value end |
Class Method Details
.ALL ⇒ Object
11024 11025 11026 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11024 def CurrencyLabelFormatter.ALL @@all ||= [CurrencyLabelFormatter.strip_trailing_zeros] end |
.apply(value) ⇒ Object
Returns the instance of CurrencyLabelFormatter for this value, creating a new instance for an unknown value
11009 11010 11011 11012 11013 11014 11015 11016 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11009 def CurrencyLabelFormatter.apply(value) if value.instance_of?(CurrencyLabelFormatter) value else HttpClient::Preconditions.assert_class_or_nil('value', value, String) value.nil? ? nil : (from_string(value) || CurrencyLabelFormatter.new(value)) end end |
.from_string(value) ⇒ Object
Returns the instance of CurrencyLabelFormatter for this value, or nil if not found
11019 11020 11021 11022 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11019 def CurrencyLabelFormatter.from_string(value) HttpClient::Preconditions.assert_class('value', value, String) CurrencyLabelFormatter.ALL.find { |v| v.value == value } end |
.strip_trailing_zeros ⇒ Object
If a price ends in ‘.00’ or ‘,00’, we remove the cents and just display the price as a whole number. e.g. ‘A$100.00’ becomes ‘A$100’
11030 11031 11032 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11030 def CurrencyLabelFormatter.strip_trailing_zeros @@_strip_trailing_zeros ||= CurrencyLabelFormatter.new('strip_trailing_zeros') end |
Instance Method Details
#to_hash ⇒ Object
11034 11035 11036 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11034 def to_hash value end |