Class: Cldr::Format::Decimal
- Inherits:
-
Object
- Object
- Cldr::Format::Decimal
- Defined in:
- lib/cldr/format/decimal.rb,
lib/cldr/format/decimal/base.rb,
lib/cldr/format/decimal/number.rb,
lib/cldr/format/decimal/integer.rb,
lib/cldr/format/decimal/fraction.rb
Defined Under Namespace
Classes: Base, Fraction, Integer, Number
Instance Attribute Summary collapse
-
#negative ⇒ Object
readonly
Returns the value of attribute negative.
-
#positive ⇒ Object
readonly
Returns the value of attribute positive.
Instance Method Summary collapse
- #apply(number, options = {}) ⇒ Object
-
#initialize(format, symbols = {}) ⇒ Decimal
constructor
A new instance of Decimal.
Constructor Details
#initialize(format, symbols = {}) ⇒ Decimal
Returns a new instance of Decimal.
11 12 13 |
# File 'lib/cldr/format/decimal.rb', line 11 def initialize(format, symbols = {}) @positive, @negative = parse_format(format, symbols) end |
Instance Attribute Details
#negative ⇒ Object (readonly)
Returns the value of attribute negative.
9 10 11 |
# File 'lib/cldr/format/decimal.rb', line 9 def negative @negative end |
#positive ⇒ Object (readonly)
Returns the value of attribute positive.
9 10 11 |
# File 'lib/cldr/format/decimal.rb', line 9 def positive @positive end |
Instance Method Details
#apply(number, options = {}) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/cldr/format/decimal.rb', line 15 def apply(number, = {}) number = Float(number) format = number.abs == number ? positive : negative format.apply(number, ) rescue TypeError, ArgumentError number end |