lib/factbase/terms/math.rb in factbase-0.2.1 vs lib/factbase/terms/math.rb in factbase-0.3.0
- old
+ new
@@ -61,10 +61,18 @@
def gt(fact, maps)
cmp(:>, fact, maps)
end
+ def lte(fact, maps)
+ cmp(:<=, fact, maps)
+ end
+
+ def gte(fact, maps)
+ cmp(:>=, fact, maps)
+ end
+
def cmp(op, fact, maps)
assert_args(2)
lefts = the_values(0, fact, maps)
return false if lefts.nil?
rights = the_values(1, fact, maps)
@@ -91,18 +99,18 @@
if v.is_a?(Time) && r.is_a?(String)
(num, units) = r.split
num = num.to_i
r =
case units
- when 'seconds'
+ when 'seconds', 'second'
num
- when 'minutes'
+ when 'minutes', 'minute'
num * 60
- when 'hours'
+ when 'hours', 'hour'
num * 60 * 60
- when 'days'
+ when 'days', 'day'
num * 60 * 60 * 24
- when 'weeks'
+ when 'weeks', 'week'
num * 60 * 60 * 24 * 7
else
raise "Unknown time unit '#{units}' in '#{r}"
end
end