Module: Qcontent::Pricing
- Defined in:
- lib/qcontent/pricing.rb
Defined Under Namespace
Modules: InstanceMethods, MacroMethods
Class Method Summary
collapse
Class Method Details
.convert_to_cents(money_like) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/qcontent/pricing.rb', line 9
def convert_to_cents(money_like)
case money_like
when String
money_like.gsub!(/[\$,\ ]/, '')
if money_like =~ /\./
money_like.gsub(/[\.]/,'').to_i
else
money_like.to_i * 100
end
when Money
money_like.cents.to_i
else
money_like.to_i
end
end
|
.convert_to_money(money_like) ⇒ Object
25
26
27
|
# File 'lib/qcontent/pricing.rb', line 25
def convert_to_money(money_like)
Money.new(convert_to_cents(money_like))
end
|
.included(klass) ⇒ Object
5
6
7
|
# File 'lib/qcontent/pricing.rb', line 5
def included(klass)
klass.extend MacroMethods
end
|