Module: Shipindo::Helpers::RupiahToFloat
- Included in:
- String
- Defined in:
- lib/shipindo/helpers/rupiah_to_float.rb
Instance Method Summary collapse
-
#rupiah_to_float(options = {}) ⇒ Object
(also: #rp_to_f)
convert rupiah string to float.
Instance Method Details
#rupiah_to_float(options = {}) ⇒ Object Also known as: rp_to_f
convert rupiah string to float
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/shipindo/helpers/rupiah_to_float.rb', line 9 def rupiah_to_float(={}) [:prefix] ||= "Rp." [:thousand_separator] ||= "." [:cent_separator] ||= "," text = self.gsub([:prefix],"").gsub([:thousand_separator],"") if text.include?([:cent_separator]) && [:cent_separator] != "." text = text.gsub([:cent_separator], ".") end text.to_f end |