Skip to content

Commit

Permalink
Merge pull request #610 from RubyMoney/fix-format-docs
Browse files Browse the repository at this point in the history
fix Money::Formatting#format docs
  • Loading branch information
semmons99 committed Feb 18, 2016
2 parents 16122fe + c6eb9be commit eb968be
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 28 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,7 @@

## Next release
- Changed DKK symbol from 'kr' to 'kr.'
- Improved Money::Formatting#format docs

## 6.7.0
- Changed `Money#<=>` to return `nil` if the comparison is inappropriate. (#584)
Expand Down
56 changes: 28 additions & 28 deletions lib/money/money/formatting.rb
Expand Up @@ -7,44 +7,44 @@ module Formatting
#
# @return [String]
#
# @option *rules [Boolean, String] :display_free (false) Whether a zero
# @option rules [Boolean, String] :display_free (false) Whether a zero
# amount of money should be formatted of "free" or as the supplied string.
#
# @example
# Money.us_dollar(0).format(:display_free => true) #=> "free"
# Money.us_dollar(0).format(:display_free => "gratis") #=> "gratis"
# Money.us_dollar(0).format #=> "$0.00"
#
# @option *rules [Boolean] :with_currency (false) Whether the currency name
# @option rules [Boolean] :with_currency (false) Whether the currency name
# should be appended to the result string.
#
# @example
# Money.ca_dollar(100).format #=> "$1.00"
# Money.ca_dollar(100).format(:with_currency => true) #=> "$1.00 CAD"
# Money.us_dollar(85).format(:with_currency => true) #=> "$0.85 USD"
#
# @option *rules [Boolean] :rounded_infinite_precision (false) Whether the
# amount of money should be rounded when using infinite_precision
# @option rules [Boolean] :rounded_infinite_precision (false) Whether the
# amount of money should be rounded when using {infinite_precision}
#
# @example
# Money.us_dollar(100.1).format #=> "$1.001"
# Money.us_dollar(100.1).format(:rounded_infinite_precision => true) #=> "$1"
# Money.us_dollar(100.9).format(:rounded_infinite_precision => true) #=> "$1.01"
#
# @option *rules [Boolean] :no_cents (false) Whether cents should be omitted.
# @option rules [Boolean] :no_cents (false) Whether cents should be omitted.
#
# @example
# Money.ca_dollar(100).format(:no_cents => true) #=> "$1"
# Money.ca_dollar(599).format(:no_cents => true) #=> "$5"
#
# @option *rules [Boolean] :no_cents_if_whole (false) Whether cents should be
# @option rules [Boolean] :no_cents_if_whole (false) Whether cents should be
# omitted if the cent value is zero
#
# @example
# Money.ca_dollar(10000).format(:no_cents_if_whole => true) #=> "$100"
# Money.ca_dollar(10034).format(:no_cents_if_whole => true) #=> "$100.34"
#
# @option *rules [Boolean, String, nil] :symbol (true) Whether a money symbol
# @option rules [Boolean, String, nil] :symbol (true) Whether a money symbol
# should be prepended to the result string. The default is true. This method
# attempts to pick a symbol that's suitable for the given currency.
#
Expand Down Expand Up @@ -75,10 +75,10 @@ module Formatting
# Money.new(10000000, "INR").format(:south_asian_number_formatting => true) #=> "1,00,000.00"
# Money.new(10000000).format(:south_asian_number_formatting => true) #=> "$1,00,000.00"
#
# @option *rules [Boolean, nil] :symbol_before_without_space (true) Whether
# a space between the money symbol and the amount should be inserted when
# +:symbol_position+ is +:before+. The default is true (meaning no space). Ignored
# if +:symbol+ is false or +:symbol_position+ is not +:before+.
# @option rules [Boolean, nil] :symbol_before_without_space (true) Whether
# a space between the money symbol and the amount should be inserted when
# +:symbol_position+ is +:before+. The default is true (meaning no space). Ignored
# if +:symbol+ is false or +:symbol_position+ is not +:before+.
#
# @example
# # Default is to not insert a space.
Expand All @@ -90,10 +90,10 @@ module Formatting
# # If set to false, will insert a space.
# Money.new(100, "USD").format(:symbol_before_without_space => false) #=> "$ 1.00"
#
# @option *rules [Boolean, nil] :symbol_after_without_space (false) Whether
# a space between the the amount and the money symbol should be inserted when
# +:symbol_position+ is +:after+. The default is false (meaning space). Ignored
# if +:symbol+ is false or +:symbol_position+ is not +:after+.
# @option rules [Boolean, nil] :symbol_after_without_space (false) Whether
# a space between the amount and the money symbol should be inserted when
# +:symbol_position+ is +:after+. The default is false (meaning space). Ignored
# if +:symbol+ is false or +:symbol_position+ is not +:after+.
#
# @example
# # Default is to insert a space.
Expand All @@ -102,7 +102,7 @@ module Formatting
# # If set to true, will not insert a space.
# Money.new(100, "USD").format(:symbol_position => :after, :symbol_after_without_space => true) #=> "1.00$"
#
# @option *rules [Boolean, String, nil] :decimal_mark (true) Whether the
# @option rules [Boolean, String, nil] :decimal_mark (true) Whether the
# currency should be separated by the specified character or '.'
#
# @example
Expand All @@ -113,7 +113,7 @@ module Formatting
# # to "." as decimal_mark.
# Money.new(100, "FOO").format #=> "$1.00"
#
# @option *rules [Boolean, String, nil] :thousands_separator (true) Whether
# @option rules [Boolean, String, nil] :thousands_separator (true) Whether
# the currency should be delimited by the specified character or ','
#
# @example
Expand All @@ -129,14 +129,14 @@ module Formatting
# # default to "," as thousands_separator.
# Money.new(100000, "FOO").format #=> "$1,000.00"
#
# @option *rules [Boolean] :html (false) Whether the currency should be
# @option rules [Boolean] :html (false) Whether the currency should be
# HTML-formatted. Only useful in combination with +:with_currency+.
#
# @example
# s = Money.ca_dollar(570).format(:html => true, :with_currency => true)
# s #=> "$5.70 <span class=\"currency\">CAD</span>"
# Money.ca_dollar(570).format(:html => true, :with_currency => true)
# #=> "$5.70 <span class=\"currency\">CAD</span>"
#
# @option *rules [Boolean] :sign_before_symbol (false) Whether the sign should be
# @option rules [Boolean] :sign_before_symbol (false) Whether the sign should be
# before the currency symbol.
#
# @example
Expand All @@ -145,7 +145,7 @@ module Formatting
# Money.new(-100, "GBP").format(:sign_before_symbol => false) #=> "£-1.00"
# Money.new(-100, "GBP").format #=> "£-1.00"
#
# @option *rules [Boolean] :sign_positive (false) Whether positive numbers should be
# @option rules [Boolean] :sign_positive (false) Whether positive numbers should be
# signed, too.
#
# @example
Expand All @@ -156,7 +156,7 @@ module Formatting
# Money.new(100, "GBP").format(:sign_positive => false, :sign_before_symbol => false) #=> "£1.00"
# Money.new(100, "GBP").format #=> "£+1.00"
#
# @option *rules [Boolean] :disambiguate (false) Prevents the result from being ambiguous
# @option rules [Boolean] :disambiguate (false) Prevents the result from being ambiguous
# due to equal symbols for different currencies. Uses the `disambiguate_symbol`.
#
# @example
Expand All @@ -165,21 +165,21 @@ module Formatting
# Money.new(10000, "USD").format(:disambiguate => true) #=> "$100.00"
# Money.new(10000, "CAD").format(:disambiguate => true) #=> "C$100.00"
#
# @option *rules [Boolean] :html_wrap_symbol (false) Wraps the currency symbol
# @option rules [Boolean] :html_wrap_symbol (false) Wraps the currency symbol
# in a html <span> tag.
#
# @example
# Money.new(10000, "USD").format(:disambiguate => false)
# #=> "<span class=\"currency_symbol\">$100.00</span>
#
# @option *rules [Symbol] :symbol_position (:before) `:before` if the currency
# @option rules [Symbol] :symbol_position (:before) `:before` if the currency
# symbol goes before the amount, `:after` if it goes after.
#
# @example
# Money.new(10000, "USD").format(:symbol_position => :before) #=> "$100.00"
# Money.new(10000, "USD").format(:symbol_position => :after) #=> "100.00 $"
#
# @option *rules [Boolean] :translate (true) `true` Checks for custom
# @option rules [Boolean] :translate (true) `true` Checks for custom
# symbol definitions using I18n.
#
# @example
Expand All @@ -195,9 +195,9 @@ module Formatting
# Money.new(89000, :btc).format(:drop_trailing_zeros => true) #=> B⃦0.00089
# Money.new(110, :usd).format(:drop_trailing_zeros => true) #=> $1.1
#
# Note that the default rules can be defined through +Money.default_formatting_rules+ hash.
# Note that the default rules can be defined through {Money.default_formatting_rules} hash.
#
# @see +Money.default_formatting_rules+ for more information.
# @see Money.default_formatting_rules Money.default_formatting_rules for more information.
def format(*rules)
# support for old format parameters
rules = normalize_formatting_rules(rules)
Expand Down

0 comments on commit eb968be

Please sign in to comment.