class Termtter::Task

Attributes

exec_at[RW]
exec_proc[RW]
interval[RW]
name[RW]
work[RW]

Public Class Methods

new(args = {}, &block) click to toggle source
# File lib/termtter/task.rb, line 5
def initialize(args = {}, &block)
  @name = args[:name]
  @exec_at = Time.now + (args[:after] || 0)
  @interval = args[:interval]
  @exec_proc = block || lambda {}
  @work = true
end

Public Instance Methods

execute() click to toggle source
# File lib/termtter/task.rb, line 12
def execute
  args = if exec_proc.arity.zero? then [] else [self] end
  exec_proc.call(*args) if work
end