Sha256: bae1bf1d269e5601d8eacf118a938eff54c8c708e9a95223a5721befc2f0a80e

Contents?: true

Size: 736 Bytes

Versions: 6

Compression:

Stored size: 736 Bytes

Contents

require 'money'

module Spree
  class Money
    attr_reader :money

    def initialize(amount, options={})
      @money = ::Money.parse([amount, (options[: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!(options)
      # Must be a symbol because the Money gem doesn't do the conversion
      @options[:symbol_position] = @options[:symbol_position].to_sym

    end

    def to_s
      @money.format(@options)
    end

    def ==(obj)
      @money == obj.money
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
spree_core-1.3.2 lib/spree/money.rb
spree_core-1.3.1 lib/spree/money.rb
spree_core-1.3.0 lib/spree/money.rb
spree_core-1.3.0.rc2 lib/spree/money.rb
dup_spree_core-1.3.0.rc1 lib/spree/money.rb
spree_core-1.3.0.rc1 lib/spree/money.rb