Class: Envirobly::Numeric

Inherits:
Numeric
  • Object
show all
Defined in:
lib/envirobly/numeric.rb

Instance Method Summary collapse

Constructor Details

#initialize(value, short: false) ⇒ Numeric

Returns a new instance of Numeric.



4
5
6
7
# File 'lib/envirobly/numeric.rb', line 4

def initialize(value, short: false)
  @value = value
  @short = short
end

Instance Method Details

#to_sObject



9
10
11
12
13
14
15
# File 'lib/envirobly/numeric.rb', line 9

def to_s
  if @short
    @value.to_s.delete_suffix(".0")
  else
    "%.2f" % @value
  end
end