Class: AWSCronParser::Parsers::AWSAt

Inherits:
Base
  • Object
show all
Defined in:
lib/aws_cron_parser/parsers/aws_at.rb

Overview

AWS one-time schedule: at(yyyy-MM-ddThh:mm:ss). Fires exactly once.

Instance Attribute Summary collapse

Attributes inherited from Base

#original_source, #source, #time_source, #time_zone

Instance Method Summary collapse

Methods inherited from Base

#last

Methods included from Helpers

included

Constructor Details

#initialize(source, time_source = Time) ⇒ AWSAt

Returns a new instance of AWSAt.

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
# File 'lib/aws_cron_parser/parsers/aws_at.rb', line 9

def initialize(source, time_source = Time)
  super

  match = source.strip.match(AT_REGEX)
  raise ArgumentError, "Invalid at format: #{source}" unless match

  @at = zone.parse(match[:datetime].strip)
end

Instance Attribute Details

#atObject (readonly)

Returns the value of attribute at.



7
8
9
# File 'lib/aws_cron_parser/parsers/aws_at.rb', line 7

def at
  @at
end

Instance Method Details

#next(now = @time_source.now) ⇒ Object

nil once the instant has passed: a one-time schedule has no further runs.



19
20
21
# File 'lib/aws_cron_parser/parsers/aws_at.rb', line 19

def next(now = @time_source.now)
  @at > ensure_time(now) ? @at : nil
end