Class: Spree::Money
- Inherits:
-
Object
- Object
- Spree::Money
- Defined in:
- lib/spree/money.rb
Instance Attribute Summary collapse
-
#money ⇒ Object
readonly
Returns the value of attribute money.
Instance Method Summary collapse
- #==(obj) ⇒ Object
-
#initialize(amount, options = {}) ⇒ Money
constructor
A new instance of Money.
- #to_s ⇒ Object
Constructor Details
#initialize(amount, options = {}) ⇒ Money
Returns a new instance of Money.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/spree/money.rb', line 7 def initialize(amount, ={}) @money = ::Money.parse([amount, ([:currency] || Spree::Config[:currency])].join) @options = {} @options[:with_currency] = true if Spree::Config[:display_currency] @options[:symbol_position] = Spree::Config[:currency_symbol_position].to_sym @options[:no_cents] = true if Spree::Config[:hide_cents] @options.merge!() # Must be a symbol because the Money gem doesn't do the conversion @options[:symbol_position] = @options[:symbol_position].to_sym end |
Instance Attribute Details
#money ⇒ Object (readonly)
Returns the value of attribute money.
5 6 7 |
# File 'lib/spree/money.rb', line 5 def money @money end |
Instance Method Details
#==(obj) ⇒ Object
23 24 25 |
# File 'lib/spree/money.rb', line 23 def ==(obj) @money == obj.money end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/spree/money.rb', line 19 def to_s @money.format(@options) end |