Class: CronParser::InternalTime

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

Overview

internal “mutable” time representation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(time = Time.now, time_source = Time) ⇒ InternalTime



12
13
14
15
16
17
18
19
20
21
# File 'lib/cron_parser.rb', line 12

def initialize(time = Time.now, time_source = Time)
  @year = time.year
  @month = time.month
  @day = time.day
  @hour = time.hour
  @min = time.min
  @sec = time.sec

  @time_source = time_source
end

Instance Attribute Details

#dayObject

Returns the value of attribute day.



9
10
11
# File 'lib/cron_parser.rb', line 9

def day
  @day
end

#hourObject

Returns the value of attribute hour.



9
10
11
# File 'lib/cron_parser.rb', line 9

def hour
  @hour
end

#minObject

Returns the value of attribute min.



9
10
11
# File 'lib/cron_parser.rb', line 9

def min
  @min
end

#monthObject

Returns the value of attribute month.



9
10
11
# File 'lib/cron_parser.rb', line 9

def month
  @month
end

#secObject

Returns the value of attribute sec.



9
10
11
# File 'lib/cron_parser.rb', line 9

def sec
  @sec
end

#time_sourceObject

Returns the value of attribute time_source.



10
11
12
# File 'lib/cron_parser.rb', line 10

def time_source
  @time_source
end

#yearObject

Returns the value of attribute year.



9
10
11
# File 'lib/cron_parser.rb', line 9

def year
  @year
end

Instance Method Details

#inspectObject



27
28
29
# File 'lib/cron_parser.rb', line 27

def inspect
  [year, month, day, hour, min, sec].inspect
end

#to_timeObject



23
24
25
# File 'lib/cron_parser.rb', line 23

def to_time
  time_source.local(@year, @month, @day, @hour, @min, @sec)
end