Class: Crntb::Line

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line) ⇒ Line

Returns a new instance of Line.



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

def initialize(line)
    fields = manipuate(line)
    @minute       = Minute.parse(fields[0])
    @hour         = Hour.parse(fields[1])
    @day_of_month = DayOfWeek.parse(fields[2])
    @month        = Month.parse(fields[3])
    @day_of_week  = DayOfMonth.parse(fields[4])
    @command      = fields[5].chomp
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



11
12
13
# File 'lib/crntb/file.rb', line 11

def command
  @command
end

#day_of_monthObject (readonly)

Returns the value of attribute day_of_month.



11
12
13
# File 'lib/crntb/file.rb', line 11

def day_of_month
  @day_of_month
end

#day_of_weekObject (readonly)

Returns the value of attribute day_of_week.



11
12
13
# File 'lib/crntb/file.rb', line 11

def day_of_week
  @day_of_week
end

#hourObject (readonly)

Returns the value of attribute hour.



11
12
13
# File 'lib/crntb/file.rb', line 11

def hour
  @hour
end

#minuteObject (readonly)

Returns the value of attribute minute.



11
12
13
# File 'lib/crntb/file.rb', line 11

def minute
  @minute
end

#monthObject (readonly)

Returns the value of attribute month.



11
12
13
# File 'lib/crntb/file.rb', line 11

def month
  @month
end

Instance Method Details

#manipuate(line) ⇒ Object



34
35
36
# File 'lib/crntb/file.rb', line 34

def manipuate(line)
  line.split(' ', 6)
end

#parseObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/crntb/file.rb', line 23

def parse
  [
    day_of_week,
    month,
    day_of_month,
    hour,
    minute,
    "\n  exec #{@command}",
  ].join
end