Class: Scheduled::CronParser::InternalTime

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

Overview

internal “mutable” time representation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(time, time_source = Time) ⇒ InternalTime

Returns a new instance of InternalTime.



37
38
39
40
41
42
43
44
45
# File 'lib/scheduled/cron_parser.rb', line 37

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

  @time_source = time_source
end

Instance Attribute Details

#dayObject

Returns the value of attribute day.



34
35
36
# File 'lib/scheduled/cron_parser.rb', line 34

def day
  @day
end

#hourObject

Returns the value of attribute hour.



34
35
36
# File 'lib/scheduled/cron_parser.rb', line 34

def hour
  @hour
end

#minObject

Returns the value of attribute min.



34
35
36
# File 'lib/scheduled/cron_parser.rb', line 34

def min
  @min
end

#monthObject

Returns the value of attribute month.



34
35
36
# File 'lib/scheduled/cron_parser.rb', line 34

def month
  @month
end

#time_sourceObject

Returns the value of attribute time_source.



35
36
37
# File 'lib/scheduled/cron_parser.rb', line 35

def time_source
  @time_source
end

#yearObject

Returns the value of attribute year.



34
35
36
# File 'lib/scheduled/cron_parser.rb', line 34

def year
  @year
end

Instance Method Details

#inspectObject



51
52
53
# File 'lib/scheduled/cron_parser.rb', line 51

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

#to_timeObject



47
48
49
# File 'lib/scheduled/cron_parser.rb', line 47

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