Class: AWSCronParser::Describer::DayComposer

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/aws_cron_parser/describer/day_composer.rb

Overview

Composes day descriptions (day-of-month and day-of-week)

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

included

Constructor Details

#initialize(config, is_aws: false) ⇒ DayComposer

Returns a new instance of DayComposer.



11
12
13
14
15
# File 'lib/aws_cron_parser/describer/day_composer.rb', line 11

def initialize(config, is_aws: false)
  @day = config[:day]
  @dow = config[:dow]
  @is_aws = is_aws
end

Instance Attribute Details

#dayObject (readonly)

Returns the value of attribute day.



9
10
11
# File 'lib/aws_cron_parser/describer/day_composer.rb', line 9

def day
  @day
end

#dowObject (readonly)

Returns the value of attribute dow.



9
10
11
# File 'lib/aws_cron_parser/describer/day_composer.rb', line 9

def dow
  @dow
end

#is_awsObject (readonly)

Returns the value of attribute is_aws.



9
10
11
# File 'lib/aws_cron_parser/describer/day_composer.rb', line 9

def is_aws
  @is_aws
end

Instance Method Details

#composeObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/aws_cron_parser/describer/day_composer.rb', line 17

def compose
  day_wildcard = wildcards?(day)
  dow_wildcard = wildcards?(dow)

  # Both wildcards - no day description
  return nil if day_wildcard && dow_wildcard

  # Only day-of-week
  return describe_dow if day_wildcard && !dow_wildcard

  # Only day-of-month
  return describe_day if !day_wildcard && dow_wildcard

  # Both specified (AWS allows this for OR logic)
  describe_both
end