Class: Lita::Schedule

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/lita/schedule.rb,
lib/lita/schedule/version.rb

Defined Under Namespace

Classes: Job

Constant Summary collapse

VERSION =
"0.0.4"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(robot) ⇒ Schedule

Returns a new instance of Schedule.



34
35
36
37
# File 'lib/lita/schedule.rb', line 34

def initialize(robot)
  @robot = robot
  @redis = Redis::Namespace.new(redis_namespace, redis: Lita.redis)
end

Instance Attribute Details

#redisObject (readonly)

Returns the value of attribute redis.



7
8
9
# File 'lib/lita/schedule.rb', line 7

def redis
  @redis
end

#robotObject (readonly)

Returns the value of attribute robot.



8
9
10
# File 'lib/lita/schedule.rb', line 8

def robot
  @robot
end

Class Method Details

.cron(field, job_name) ⇒ Object



13
14
15
# File 'lib/lita/schedule.rb', line 13

def cron(field, job_name)
  jobs << Job.new(:cron, field, job_name)
end

.every(field, job_name) ⇒ Object



17
18
19
# File 'lib/lita/schedule.rb', line 17

def every(field, job_name)
  jobs << Job.new(:cycle, field, job_name)
end

.jobsObject



21
22
23
# File 'lib/lita/schedule.rb', line 21

def jobs
  @jobs ||= []
end

.namespaceObject



25
26
27
28
29
30
31
# File 'lib/lita/schedule.rb', line 25

def namespace
  if name
    Util.underscore(name.split("::").last)
  else
    raise "Schedules that are anonymous classes must define self.name."
  end
end