Last active
December 6, 2016 05:48
-
-
Save printercu/022b0ee5bc3db99cd5bc to your computer and use it in GitHub Desktop.
Set custom symbol for currency in Money gem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2.2.1 (main):0[1] > Money.new(100, :RUB).currency.symbol | |
=> "₽" | |
2.2.1 (main):0[2] > show-method Money.new(100, :RUB).currency.symbol | |
From: /Users/max/.rvm/gems/ruby-2.2.1/gems/money-6.5.1/lib/money/currency.rb @ line 211: | |
Owner: Money::Currency | |
Visibility: public | |
Number of lines: 3 | |
attr_reader :id, :priority, :iso_code, :iso_numeric, :name, :symbol, | |
:disambiguate_symbol, :html_entity, :subunit, :subunit_to_unit, :decimal_mark, | |
:thousands_separator, :symbol_first, :smallest_denomination | |
2.2.1 (main):0[5] > cd Money.new(100, :RUB).currency | |
2.2.1 (RUB):1[6] > show-method initialize | |
From: /Users/max/.rvm/gems/ruby-2.2.1/gems/money-6.5.1/lib/money/currency.rb @ line 227: | |
Owner: Money::Currency | |
Visibility: private | |
Number of lines: 8 | |
def initialize(id) | |
# cut... | |
initialize_data! | |
end | |
2.2.1 (RUB):1[7] > show-method initialize_data! | |
From: /Users/max/.rvm/gems/ruby-2.2.1/gems/money-6.5.1/lib/money/currency.rb @ line 416: | |
Owner: Money::Currency | |
Visibility: private | |
Number of lines: 17 | |
def initialize_data! | |
data = self.class.table[@id] | |
# cut... | |
@symbol = data[:symbol] | |
# cut... | |
end | |
2.2.1 (RUB):1[8] > self.class.table | |
=> { | |
:aed => { | |
# cut.... | |
2.2.1 (RUB):1[9] > self.class.table[:rub] | |
=> { | |
# cut... | |
:symbol => "₽", | |
# cut... | |
2.2.1 (RUB):1[11] > self.class.table[:rub][:symbol] = 'rub' | |
=> "rub" | |
2.2.1 (RUB):1[12] > Money.new(100, :RUB).currency.symbol | |
=> "rub" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment