Class: Float

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

Instance Method Summary collapse

Instance Method Details

#hoursObject



14
15
16
17
18
19
20
21
22
# File 'lib/jeweler/utils/core_ext/Float.rb', line 14

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/Float.rb', line 30

def money
  require 'action_view'
  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/Float.rb', line 2

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

#rateObject



24
25
26
27
28
# File 'lib/jeweler/utils/core_ext/Float.rb', line 24

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