Module: VesperNumber
- Defined in:
- lib/vesper/framework/plugins/core-extensions.vpi/application/number.rb
Instance Method Summary collapse
Instance Method Details
#dollarize ⇒ Object
3 4 5 6 |
# File 'lib/vesper/framework/plugins/core-extensions.vpi/application/number.rb', line 3 def dollarize num = self "$%.2f" % num.to_f end |
#even? ⇒ Boolean
8 9 10 |
# File 'lib/vesper/framework/plugins/core-extensions.vpi/application/number.rb', line 8 def even? self%2 == 0 end |
#odd? ⇒ Boolean
12 13 14 |
# File 'lib/vesper/framework/plugins/core-extensions.vpi/application/number.rb', line 12 def odd? self%2 != 0 end |
#truncate_to_decimal(dec = 1) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/vesper/framework/plugins/core-extensions.vpi/application/number.rb', line 16 def truncate_to_decimal dec = 1 num = self rounded = "%.#{dec}f" % num.to_f rounded = rounded.to_s.split('.').first if rounded.to_s.end_with?('0') rounded.to_f end |