module Matt

Constants

VERSION

Public Class Methods

alltime_predicate() click to toggle source
# File lib/matt.rb, line 26
def alltime_predicate
  Predicate.tautology
end
between_predicate(from, to) click to toggle source
# File lib/matt.rb, line 53
def between_predicate(from, to)
  raise Error, "Invalid predicate `#{arg}`" unless from = Date.parse(from)
  raise Error, "Invalid predicate `#{arg}`" unless to = Date.parse(to)
  Predicate.gte(:at, from) & Predicate.lt(:at, to)
end
env(which, default = nil) click to toggle source
# File lib/matt.rb, line 13
def env(which, default = nil)
  val = ENV.has_key?(which) ? ENV[which] : default
  val = val.strip if val.is_a?(String)
  val
end
env!(which) click to toggle source
# File lib/matt.rb, line 20
def env!(which)
  raise Matt::Error, "Missing env var `#{which}`" unless ENV.has_key?(which)
  env(which)
end
last_predicate(arg) click to toggle source
# File lib/matt.rb, line 41
def last_predicate(arg)
  raise Error, "Invalid predicate `#{arg}`" unless arg.strip =~ /^(\d+)days$/
  Predicate.gte(:at, Date.today - $1.to_i) & Predicate.lt(:at, Date.today + 1)
end
since_predicate(arg) click to toggle source
# File lib/matt.rb, line 47
def since_predicate(arg)
  raise Error, "Invalid predicate `#{arg}`" unless since = Date.parse(arg)
  Predicate.gte(:at, since) & Predicate.lt(:at, Date.today + 1)
end
today_predicate() click to toggle source
# File lib/matt.rb, line 36
def today_predicate
  Predicate.gte(:at, Date.today) & Predicate.lt(:at, Date.today + 1)
end
yesterday_predicate() click to toggle source
# File lib/matt.rb, line 31
def yesterday_predicate
  Predicate.gte(:at, Date.today - 1) & Predicate.lt(:at, Date.today)
end

Private Instance Methods

alltime_predicate() click to toggle source
# File lib/matt.rb, line 26
def alltime_predicate
  Predicate.tautology
end
between_predicate(from, to) click to toggle source
# File lib/matt.rb, line 53
def between_predicate(from, to)
  raise Error, "Invalid predicate `#{arg}`" unless from = Date.parse(from)
  raise Error, "Invalid predicate `#{arg}`" unless to = Date.parse(to)
  Predicate.gte(:at, from) & Predicate.lt(:at, to)
end
env(which, default = nil) click to toggle source
# File lib/matt.rb, line 13
def env(which, default = nil)
  val = ENV.has_key?(which) ? ENV[which] : default
  val = val.strip if val.is_a?(String)
  val
end
env!(which) click to toggle source
# File lib/matt.rb, line 20
def env!(which)
  raise Matt::Error, "Missing env var `#{which}`" unless ENV.has_key?(which)
  env(which)
end
last_predicate(arg) click to toggle source
# File lib/matt.rb, line 41
def last_predicate(arg)
  raise Error, "Invalid predicate `#{arg}`" unless arg.strip =~ /^(\d+)days$/
  Predicate.gte(:at, Date.today - $1.to_i) & Predicate.lt(:at, Date.today + 1)
end
since_predicate(arg) click to toggle source
# File lib/matt.rb, line 47
def since_predicate(arg)
  raise Error, "Invalid predicate `#{arg}`" unless since = Date.parse(arg)
  Predicate.gte(:at, since) & Predicate.lt(:at, Date.today + 1)
end
today_predicate() click to toggle source
# File lib/matt.rb, line 36
def today_predicate
  Predicate.gte(:at, Date.today) & Predicate.lt(:at, Date.today + 1)
end
yesterday_predicate() click to toggle source
# File lib/matt.rb, line 31
def yesterday_predicate
  Predicate.gte(:at, Date.today - 1) & Predicate.lt(:at, Date.today)
end