Module: Redmineup::Patches::LiquidPatch::StandardFilters

Defined in:
lib/redmineup/patches/liquid_patch.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/redmineup/patches/liquid_patch.rb', line 6

def self.included(base)
  base.class_eval do
    
    private
    
    def to_number(obj)
      case obj
      when Float
        BigDecimal(obj.to_s)
      when Numeric
        obj
      when String
        (obj.strip =~ /^\d+\.\d+$/) ? BigDecimal(obj) : obj.to_i
      else
        0
      end
    end
  end
end