module JekyllMoney2::Core
Public Instance Methods
money(value, currency = "USD", options = {})
click to toggle source
# File lib/jekyll-money2/core.rb, line 15 def money(value, currency = "USD", options = {}) @defaults = defaults unless defined?(@defaults) @options = @defaults.merge(options) value = validate_money!(value, currency) format_money(value, currency, options) end
money_from_amount(value, currency = 'USD', options = {})
click to toggle source
# File lib/jekyll-money2/core.rb, line 23 def money_from_amount(value, currency = 'USD', options = {}) @defaults = defaults unless defined?(@defaults) @options = @defaults.merge(options) value = Money.from_amount(value.to_f, currency) format_money(value, currency, options) end
Private Instance Methods
defaults()
click to toggle source
@see www.rubydoc.info/gems/money/
# File lib/jekyll-money2/core.rb, line 42 def defaults { "conversion_precision" => Money.conversion_precision, "default_bank" => Money.default_bank, "default_currency" => Money.default_currency, "default_formatting_rules" => Money.default_formatting_rules, "infinite_precision" => Money.infinite_precision, "rounding_mode" => Money.rounding_mode, "use_i18n" => Money.use_i18n } end
format_money(value, currency = "USD", options = {})
click to toggle source
# File lib/jekyll-money2/core.rb, line 37 def format_money(value, currency = "USD", options = {}) Money.new(value, currency).format end
validate_money!(value, currency)
click to toggle source
# File lib/jekyll-money2/core.rb, line 33 def validate_money!(value, currency) Money.new(value, currency) end