Class: NumberToLove::LoveNumber
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- NumberToLove::LoveNumber
- Defined in:
- lib/number_to_love/love_number.rb
Constant Summary collapse
- HUMAN_ACCESSORS =
[:precision, :significant, :units, :strip_insignificant_zeros, :delimiter, :separator, :format]
- CUSTOM_ACCESSORS =
[:minimalize]
- ALL_ACCESSORS =
HUMAN_ACCESSORS | CUSTOM_ACCESSORS
- VERBOSE_UNITS =
{}
- ABBREVIATED_DECIMAL_UNITS =
{ unit: "", # ten: # one: Ten # other: Tens # hundred: Hundred thousand: "K", million: "M", billion: "B", trillion: "T" }
Instance Method Summary collapse
-
#initialize(val, opts = {}) ⇒ LoveNumber
constructor
A new instance of LoveNumber.
- #inspect ⇒ Object
- #to_s ⇒ Object
- #to_v ⇒ Object
Constructor Details
#initialize(val, opts = {}) ⇒ LoveNumber
Returns a new instance of LoveNumber.
29 30 31 32 33 34 35 36 37 |
# File 'lib/number_to_love/love_number.rb', line 29 def initialize(val, opts={}) @value = val (opts) @units = ABBREVIATED_DECIMAL_UNITS super(@value) end |
Instance Method Details
#inspect ⇒ Object
50 51 52 |
# File 'lib/number_to_love/love_number.rb', line 50 def inspect to_s end |
#to_s ⇒ Object
44 45 46 47 |
# File 'lib/number_to_love/love_number.rb', line 44 def to_s opts = number_to_human(@value, opts[:number_to_human]) end |
#to_v ⇒ Object
39 40 41 |
# File 'lib/number_to_love/love_number.rb', line 39 def to_v @value end |