Class: Vangogh::Number
- Inherits:
-
Object
- Object
- Vangogh::Number
- Defined in:
- lib/vangogh/number.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #abbreviate ⇒ Object
- #abstract ⇒ Object
-
#initialize(value) ⇒ Number
constructor
A new instance of Number.
Constructor Details
#initialize(value) ⇒ Number
Returns a new instance of Number.
6 7 8 9 10 11 12 |
# File 'lib/vangogh/number.rb', line 6 def initialize(value) if value.is_a?(String) @value = value.strip.to_f else @value = value end end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
4 5 6 |
# File 'lib/vangogh/number.rb', line 4 def value @value end |
Instance Method Details
#abbreviate ⇒ Object
18 19 20 |
# File 'lib/vangogh/number.rb', line 18 def abbreviate SI.convert(abstract).sub(/0+([a-z])/i, "\\1").sub(/\.([a-z])/i, "\\1") end |
#abstract ⇒ Object
14 15 16 |
# File 'lib/vangogh/number.rb', line 14 def abstract value.round(1 - abstracted_digits) end |