Class: Midnight::Converter

Inherits:
Object
  • Object
show all
Defined in:
lib/midnight/converter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#exprObject

Returns the value of attribute expr.



2
3
4
# File 'lib/midnight/converter.rb', line 2

def expr
  @expr
end

#tokensObject

Returns the value of attribute tokens.



2
3
4
# File 'lib/midnight/converter.rb', line 2

def tokens
  @tokens
end

Instance Method Details

#convert_tokens_to_cron_expression(tokens) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/midnight/converter.rb', line 4

def convert_tokens_to_cron_expression(tokens)
  @expr = Midnight::CronExpression.new
  @tokens = tokens

  return @expr if @tokens.empty? || tokens.detect { |t| t.type == :special }

  detect_minute_repetition
  detect_hour_repetition
  detect_day_repetition
  detect_weekday_repetition
  detect_week_repetition
  detect_month_repetition
  detect_year_repetition

  #puts tokens.inspect
  @expr
end