Class: CloudwatchChrono::Fields::Wday

Inherits:
Chrono::Fields::Wday
  • Object
show all
Defined in:
lib/cloudwatch_chrono/fields/wday.rb

Constant Summary collapse

CLOUDWATCH_REGEXP =
%r<\A(?:(?<step>(?:\*|\?|(?:(?<atom>\d+|sun|mon|tue|wed|thu|fri|sat)(?:-\g<atom>)?))(?:/\d+)?)(?:,\g<step>)*)\z>ix.freeze

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ Wday

Returns a new instance of Wday.



8
9
10
11
12
13
14
15
16
17
# File 'lib/cloudwatch_chrono/fields/wday.rb', line 8

def initialize(source)
  if source == 'L'
    @last_wday = true
  else
    unless CLOUDWATCH_REGEXP =~ source
      raise InvalidField.new('Unparsable field', source)
    end
  end
  @source = source
end

Instance Method Details

#interpolatedObject



19
20
21
22
23
24
25
# File 'lib/cloudwatch_chrono/fields/wday.rb', line 19

def interpolated
  if @last_wday
    '6-6'
  else
    super.gsub("?", "#{range.first}-#{range.last}")
  end
end