Class: Sheng::Filters::CurrencyFormattingFilter
- Defined in:
- lib/sheng/filters/currency_formatting_filter.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Sheng::Filters::Base
Instance Method Details
#filter(value) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/sheng/filters/currency_formatting_filter.rb', line 8 def filter(value) return value unless Sheng::Support.is_numeric?(value) value = Sheng::Support.typecast_numeric(value) integer, fractional = ("%00.2f" % value).split(".") if integer.length > 3 insert_commas(integer) end "#{arguments.first}#{integer}.#{fractional}" end |