Class: Crntb::Line
- Inherits:
-
Object
- Object
- Crntb::Line
- Defined in:
- lib/crntb/file.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#day_of_month ⇒ Object
readonly
Returns the value of attribute day_of_month.
-
#day_of_week ⇒ Object
readonly
Returns the value of attribute day_of_week.
-
#hour ⇒ Object
readonly
Returns the value of attribute hour.
-
#minute ⇒ Object
readonly
Returns the value of attribute minute.
-
#month ⇒ Object
readonly
Returns the value of attribute month.
Instance Method Summary collapse
-
#initialize(line) ⇒ Line
constructor
A new instance of Line.
- #manipuate(line) ⇒ Object
- #parse ⇒ Object
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
#command ⇒ Object (readonly)
Returns the value of attribute command.
11 12 13 |
# File 'lib/crntb/file.rb', line 11 def command @command end |
#day_of_month ⇒ Object (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_week ⇒ Object (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 |
#hour ⇒ Object (readonly)
Returns the value of attribute hour.
11 12 13 |
# File 'lib/crntb/file.rb', line 11 def hour @hour end |
#minute ⇒ Object (readonly)
Returns the value of attribute minute.
11 12 13 |
# File 'lib/crntb/file.rb', line 11 def minute @minute end |
#month ⇒ Object (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 |
#parse ⇒ Object
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 |