Class: BigDecimal

Inherits:
Object show all
Defined in:
lib/jeweler/utils/core_ext/BigDecimal.rb

Instance Method Summary collapse

Instance Method Details

#hoursObject



20
21
22
23
24
25
26
27
28
# File 'lib/jeweler/utils/core_ext/BigDecimal.rb', line 20

def hours
  result = self.prettify
  if result == 1
    result = result.to_s + ' hr'
  else
    result = result.to_s + ' hrs'
  end
  return result
end

#moneyObject



30
31
32
33
34
35
# File 'lib/jeweler/utils/core_ext/BigDecimal.rb', line 30

def money
  require 'action_view/helpers/number_helper'
  result = self.prettify
  result = ActionView::Base.new.number_to_currency(result).to_s
  return result
end

#prettifyObject



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/jeweler/utils/core_ext/BigDecimal.rb', line 2

def prettify
  if self.nil?
    return 0
  else
    if self.to_i == self
      return self.to_f.round(0)
    else
      return self
    end
  end
end

#rateObject



14
15
16
17
18
# File 'lib/jeweler/utils/core_ext/BigDecimal.rb', line 14

def rate
  result = self.prettify.to_s
  result = '$' + result + ' /hr'
  result
end