module Liquid::StandardFilters

Private Instance Methods

to_number(obj) click to toggle source

FIXME: Handle DateTime, Date and Time objects, convert them into seconds (integer)

# File lib/locomotive/steam/liquid/patches.rb, line 49
def to_number(obj)
  case obj
  when Numeric
    obj
  when String
    (obj.strip =~ /^\d+\.\d+$/) ? obj.to_f : obj.to_i
  when DateTime, Date, Time
    obj.to_time.to_i
  else
    0
  end
end