Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Currency symbol position when formatting #183

Closed
ksol opened this Issue · 2 comments

3 participants

@ksol

Hi,

after a quick look in the readme and the api doc, it seems to me that there is no option to configure wether the currency symbol is prepended (as in '$100') or appended (as in '100€') when formatting. So, in order : is this something I missed ? If not, do you want to propose this option? Are you planning to do so or can I look into it ?

Also, another option that could be of some use is having a space between the currency and the amount.

Thanks for your time !

@weppos
Owner

The order is defined as part of the Currency in the :symbol_first property.

If you have specific needs that go beyond the default formatting, keep in mind you can always use #to_s and #symbol to prepare your own helper.

c = Money.new(100)
# => #<Money cents:100 currency:USD>

puts "#{c} #{c.symbol}"
# => "1.00 $"

I would avoid haking the #format method because it's already very complex and it's really that simple to format the object the way you want using the methods above.

@semmons99 semmons99 closed this
@ksol

Thanks a lot. I went with "#{c} #{c.symbol}", it indeed is clear & simple enough :)

@weppos weppos was assigned
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.