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.
-
.symbol_prefix ⇒ Object
Indicates that a currency symbol should appear as a prefix to the price label.
-
.symbol_suffix ⇒ Object
Indicates that a currency symbol should appear as a suffix to the price label.
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.
18236 18237 18238 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18236 def initialize(value) @value = HttpClient::Preconditions.assert_class('value', value, String) end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
18234 18235 18236 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18234 def value @value end |
Class Method Details
.ALL ⇒ Object
18256 18257 18258 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18256 def CurrencyLabelFormatter.ALL @@all ||= [CurrencyLabelFormatter.strip_trailing_zeros, CurrencyLabelFormatter.symbol_prefix, CurrencyLabelFormatter.symbol_suffix] end |
.apply(value) ⇒ Object
Returns the instance of CurrencyLabelFormatter for this value, creating a new instance for an unknown value
18241 18242 18243 18244 18245 18246 18247 18248 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18241 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
18251 18252 18253 18254 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18251 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’
18262 18263 18264 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18262 def CurrencyLabelFormatter.strip_trailing_zeros @@_strip_trailing_zeros ||= CurrencyLabelFormatter.new('strip_trailing_zeros') end |
.symbol_prefix ⇒ Object
Indicates that a currency symbol should appear as a prefix to the price label. e.g $100
18268 18269 18270 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18268 def CurrencyLabelFormatter.symbol_prefix @@_symbol_prefix ||= CurrencyLabelFormatter.new('symbol_prefix') end |
.symbol_suffix ⇒ Object
Indicates that a currency symbol should appear as a suffix to the price label. e.g 100 $
18274 18275 18276 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18274 def CurrencyLabelFormatter.symbol_suffix @@_symbol_suffix ||= CurrencyLabelFormatter.new('symbol_suffix') end |
Instance Method Details
#to_hash ⇒ Object
18278 18279 18280 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18278 def to_hash value end |