Class: CronTable::Definition

Inherits:
Struct
  • Object
show all
Defined in:
lib/cron-table/definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#blockObject

Returns the value of attribute block

Returns:

  • (Object)

    the current value of block



2
3
4
# File 'lib/cron-table/definition.rb', line 2

def block
  @block
end

#everyObject

Returns the value of attribute every

Returns:

  • (Object)

    the current value of every



2
3
4
# File 'lib/cron-table/definition.rb', line 2

def every
  @every
end

#keyObject

Returns the value of attribute key

Returns:

  • (Object)

    the current value of key



2
3
4
# File 'lib/cron-table/definition.rb', line 2

def key
  @key
end

Instance Method Details

#next_run_at(context) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/cron-table/definition.rb', line 5

def next_run_at(context)
  case every
  when ActiveSupport::Duration
    (context.last_run_at || Time.current) + every
  when Symbol
    CronTable.every.fetch(every).call(context)
  end
end