Module: Custom::CurrencyHelper

Includes:
SelectHelper
Included in:
Lease::BidSerializer, Lease::RebateSerializer, Lib::Boats::RentPricePerSeason, Lib::Boats::SalePrice
Defined in:
app/helpers/custom/currency_helper.rb

Instance Method Summary collapse

Methods included from SelectHelper

#collection_for_select, #collection_name_by_id

Instance Method Details

#currency_attribute_name(name, currency = nil) ⇒ Object

Parameters:

  • name (Symbol, String)

    Например: ‘charter_1_day_high`



15
16
17
18
# File 'app/helpers/custom/currency_helper.rb', line 15

def currency_attribute_name name, currency = nil
  currency ||= cookies[:currency]
  Currency.attribute_name(currency, name)
end

#currency_for_label(options = {}) ⇒ Object



8
9
10
11
# File 'app/helpers/custom/currency_helper.rb', line 8

def currency_for_label(options = {})
  options[:prefix] ||= ', '
  "#{options[:prefix]}#{currency_symbol}"
end

#currency_symbol(currency = nil) ⇒ Object



3
4
5
6
# File 'app/helpers/custom/currency_helper.rb', line 3

def currency_symbol(currency = nil)
  currency ||= cookies[:currency]
  collection_name_by_id(I18n.t('static.currencies', default: ''), currency) || ''
end

#num_to_cur(val, iso_code, locale) ⇒ Object



23
24
25
26
# File 'app/helpers/custom/currency_helper.rb', line 23

def num_to_cur(val, iso_code, locale)
  unit = collection_name_by_id(I18n.t('static.currencies', default: ''), iso_code)
  number_to_currency(val, unit: unit, locale: locale)
end