Module: MoneyRails::ActionViewExtension
- Defined in:
- lib/money-rails/helpers/action_view_extension.rb
Instance Method Summary collapse
- #currency_symbol ⇒ Object
- #humanized_money(value, options = {}) ⇒ Object
- #humanized_money_with_symbol(value, options = {}) ⇒ Object
- #money_without_cents(value, options = {}) ⇒ Object
- #money_without_cents_and_with_symbol(value) ⇒ Object
Instance Method Details
#currency_symbol ⇒ Object
4 5 6 |
# File 'lib/money-rails/helpers/action_view_extension.rb', line 4 def currency_symbol content_tag(:span, Money.default_currency.symbol, :class => "currency_symbol") end |
#humanized_money(value, options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/money-rails/helpers/action_view_extension.rb', line 8 def humanized_money(value, ={}) if ! || !.is_a?(Hash) warn "humanized_money now takes a hash of formatting options, please specify { :symbol => true }" = { :symbol => } end unless value.is_a?(Money) if value.respond_to?(:to_money) value = value.to_money else return '' end end = { :no_cents_if_whole => MoneyRails::Configuration.no_cents_if_whole.nil? ? true : MoneyRails::Configuration.no_cents_if_whole, :symbol => false, :decimal_mark => value.currency.decimal_mark, :thousands_separator => value.currency.thousands_separator }.merge() .delete(:symbol) if [:disambiguate] value.format() end |
#humanized_money_with_symbol(value, options = {}) ⇒ Object
33 34 35 |
# File 'lib/money-rails/helpers/action_view_extension.rb', line 33 def humanized_money_with_symbol(value, ={}) humanized_money(value, .merge(:symbol => true)) end |
#money_without_cents(value, options = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/money-rails/helpers/action_view_extension.rb', line 37 def money_without_cents(value, ={}) if ! || !.is_a?(Hash) warn "money_without_cents now takes a hash of formatting options, please specify { :symbol => true }" = { :symbol => } end = { :no_cents => true, :no_cents_if_whole => false, :symbol => false }.merge() humanized_money(value, ) end |
#money_without_cents_and_with_symbol(value) ⇒ Object
52 53 54 |
# File 'lib/money-rails/helpers/action_view_extension.rb', line 52 def money_without_cents_and_with_symbol(value) money_without_cents(value, :symbol => true) end |