Module: TaskLoop::TaskProperty
- Included in:
- Task
- Defined in:
- lib/taskloop/task/task_property.rb
Constant Summary collapse
- WEEK =
{ :Sun => 0, :Mon => 1, :Tue => 2, :Wed => 3, :Thu => 4, :Fri => 5, :Sat => 6, }
- MONTH =
{ :Jan => 1, :Feb => 2, :Mar => 3, :Apr => 4, :Jun => 6, :Jul => 7, :Aug => 8, :Sep => 9, :Oct => 10, :Nov => 11, :Dec => 12, :mon1 => 1, :mon2 => 2, :mon3 => 3, :mon4 => 4, :mon5 => 5, :mon6 => 6, :mon7 => 7, :mon8 => 8, :mon9 => 9, :mon10 => 10, :mon11 => 11, :mon12 => 12, }
- DAY =
{ :day1 => 1, :day2 => 2, :day3 => 3, :day4 => 4, :day5 => 5, :day6 => 6, :day7 => 7, :day8 => 8, :day9 => 9, :day10 => 10, :day11 => 11, :day12 => 12, :day13 => 13, :day14 => 14, :day15 => 15, :day16 => 16, :day17 => 17, :day18 => 18, :day19 => 19, :day20 => 20, :day21 => 21, :day22 => 22, :day23 => 23, :day24 => 24, :day25 => 25, :day26 => 26, :day27 => 27, :day28 => 28, :day29 => 29, :day30 => 30, :day31 => 31, }
Instance Attribute Summary collapse
-
#name ⇒ Object
the name of task.
-
#path ⇒ Object
the path of task.
Instance Method Summary collapse
- #date ⇒ Object
-
#date=(rule) ⇒ Object
Date Property date list syntax - date - example: date “2023-10-10”, “2013-10-11”, “2023-11-10”.
- #day ⇒ Object
-
#day=(rule) ⇒ Object
Day Property specific syntax - at - example: at :day1, :day2, :day3 …
- #end_point ⇒ Object
-
#end_point=(rule) ⇒ Object
EndPoint Property boundary syntax - end_point - example: to “2023-10-11 10:00:00”.
- #has_date? ⇒ Boolean
- #has_hm? ⇒ Boolean
- #has_interval_rule? ⇒ Boolean
- #has_time? ⇒ Boolean
-
#has_week? ⇒ Boolean
Help Methods.
- #has_ymd? ⇒ Boolean
- #hour ⇒ Object
-
#hour=(rule) ⇒ Object
Hour Property specific syntax - at - example: at 10, 11, 13 …
- #last_time ⇒ Object
- #loop ⇒ Object
-
#loop=(rule) ⇒ Object
Loop Property loop syntax - loop - example: loop 5.times.
- #loop_count ⇒ Object
- #minute ⇒ Object
-
#minute=(rule) ⇒ Object
Minute Property specific syntax - at - example: at 59, 23 …
- #month ⇒ Object
-
#month=(rule) ⇒ Object
Month Property specific syntax - at - example: at :Jan, :Feb, :Mar, :Apr, :Jun, :Jul, :Aug, :Sep, :Oct, :Nov, :Dec; - example: at :month1, :month2, :month3 …
- #start_point ⇒ Object
-
#start_point=(rule) ⇒ Object
StartPoint Property boundary syntax - start_point - example: from “2023-10-11 10:00:00”.
- #time ⇒ Object
-
#time=(rule) ⇒ Object
Time Property time list syntax - time - example: time “10:10:30”, “9:10:20”, “20:10:20”.
- #week ⇒ Object
-
#week=(rule) ⇒ Object
Week Property specific syntax - at - example: at :Mon, :Tue, :Fri scope syntax - before - example: before :Mon - between - example: between :Mon, :Fri - after 0 example: after :Tue.
- #year ⇒ Object
-
#year=(rule) ⇒ Object
Year Property specific syntax - of - example: at 2024, 2025 …
Instance Attribute Details
#name ⇒ Object
the name of task
74 75 76 |
# File 'lib/taskloop/task/task_property.rb', line 74 def name @name end |
#path ⇒ Object
the path of task
76 77 78 |
# File 'lib/taskloop/task/task_property.rb', line 76 def path @path end |
Instance Method Details
#date ⇒ Object
287 288 289 |
# File 'lib/taskloop/task/task_property.rb', line 287 def date @date ||= DefaultRule.new(:date) end |
#date=(rule) ⇒ Object
Date Property date list syntax
- date
- example: date "2023-10-10", "2013-10-11", "2023-11-10"
279 280 281 282 283 284 285 286 |
# File 'lib/taskloop/task/task_property.rb', line 279 def date=(rule) unless rule.is_a?(DateListRule) raise TypeError, "the rule of time must be DateListRule" end @date = rule @date.unit = :date end |
#day ⇒ Object
185 186 187 |
# File 'lib/taskloop/task/task_property.rb', line 185 def day @day ||= DefaultRule.new(:day) end |
#day=(rule) ⇒ Object
Day Property specific syntax
- at
- example: at :day1, :day2, :day3 ...
interval syntax
- interval
- example: interval 10.day
scope syntax
- before
- example: before :day10
- between
- example: between :day10, :day19
- example: between :Mon, :Fri
- after
- example: after :day10
177 178 179 180 181 182 183 |
# File 'lib/taskloop/task/task_property.rb', line 177 def day=(rule) unless rule.is_a?(SpecificRule) || rule.is_a?(ScopeRule) || rule.is_a?(IntervalRule) raise TypeError, "the rule of day must be SpecificRule or ScopeRule or IntervalRule" end @day = rule @day.unit = :day end |
#end_point ⇒ Object
323 324 325 |
# File 'lib/taskloop/task/task_property.rb', line 323 def end_point @end_point ||= DefaultRule.new(:full) end |
#end_point=(rule) ⇒ Object
EndPoint Property boundary syntax
- end_point
- example: to "2023-10-11 10:00:00"
315 316 317 318 319 320 321 |
# File 'lib/taskloop/task/task_property.rb', line 315 def end_point=(rule) unless rule.is_a?(EndPointBoundaryRule) raise TypeError, "the rule of end_point must be EndPointBoundaryRule" end @end_point = rule @end_point.unit = :full end |
#has_date? ⇒ Boolean
333 334 335 |
# File 'lib/taskloop/task/task_property.rb', line 333 def has_date? !date.is_a?(DefaultRule) end |
#has_hm? ⇒ Boolean
345 346 347 |
# File 'lib/taskloop/task/task_property.rb', line 345 def has_hm? [hour, minute].any? { |rule| !rule.is_a?(DefaultRule) } end |
#has_interval_rule? ⇒ Boolean
349 350 351 352 |
# File 'lib/taskloop/task/task_property.rb', line 349 def has_interval_rule? rules = [year, month, day, hour, minute] return rules.any?{ |rule| rule.is_a?(IntervalRule) } end |
#has_time? ⇒ Boolean
337 338 339 |
# File 'lib/taskloop/task/task_property.rb', line 337 def has_time? !time.is_a?(DefaultRule) end |
#has_week? ⇒ Boolean
Help Methods
330 331 332 |
# File 'lib/taskloop/task/task_property.rb', line 330 def has_week? !week.is_a?(DefaultRule) end |
#has_ymd? ⇒ Boolean
341 342 343 |
# File 'lib/taskloop/task/task_property.rb', line 341 def has_ymd? [year, month, day].any? { |rule| !rule.is_a?(DefaultRule) } end |
#hour ⇒ Object
213 214 215 |
# File 'lib/taskloop/task/task_property.rb', line 213 def hour @hour ||= DefaultRule.new(:hour) end |
#hour=(rule) ⇒ Object
Hour Property specific syntax
- at
- example: at 10, 11, 13 ...
interval syntax
- interval
- example: interval 10.hour
scope syntax
- before
- example: before 9
- between
- example: between 10, 12
- after
- example: after 11
205 206 207 208 209 210 211 |
# File 'lib/taskloop/task/task_property.rb', line 205 def hour=(rule) unless rule.is_a?(SpecificRule) || rule.is_a?(ScopeRule) || rule.is_a?(IntervalRule) raise TypeError, "the rule of hour must be SpecificRule or ScopeRule or IntervalRule" end @hour = rule @hour.unit = :hour end |
#last_time ⇒ Object
362 363 364 365 366 367 368 |
# File 'lib/taskloop/task/task_property.rb', line 362 def last_time = 0 File.open(timefile_path, 'r') do |file| = file.gets.to_i end return Time.at() end |
#loop ⇒ Object
251 252 253 |
# File 'lib/taskloop/task/task_property.rb', line 251 def loop @loop ||= DefaultRule.new(:loop) end |
#loop=(rule) ⇒ Object
Loop Property loop syntax
- loop
- example: loop 5.times
243 244 245 246 247 248 249 250 |
# File 'lib/taskloop/task/task_property.rb', line 243 def loop=(rule) unless rule.is_a?(LoopRule) raise TypeError, "the rule of loop must be LoopRule" end @loop = rule @loop.unit = :loop end |
#loop_count ⇒ Object
354 355 356 357 358 359 360 |
# File 'lib/taskloop/task/task_property.rb', line 354 def loop_count count = 0 File.open(loopfile_path, 'r') do |file| count = file.gets.to_i end return count end |
#minute ⇒ Object
233 234 235 |
# File 'lib/taskloop/task/task_property.rb', line 233 def minute @minute ||= DefaultRule.new(:minute) end |
#minute=(rule) ⇒ Object
Minute Property specific syntax
- at
- example: at 59, 23 ...
interval syntax
- interval
- example: interval 5.minute
225 226 227 228 229 230 231 |
# File 'lib/taskloop/task/task_property.rb', line 225 def minute=(rule) unless rule.is_a?(SpecificRule) || rule.is_a?(IntervalRule) raise TypeError, "the rule of minute must be SpecificRule or IntervalRule" end @minute = rule @minute.unit = :minute end |
#month ⇒ Object
156 157 158 |
# File 'lib/taskloop/task/task_property.rb', line 156 def month @month||= DefaultRule.new(:month) end |
#month=(rule) ⇒ Object
Month Property specific syntax
- at
- example: at :Jan, :Feb, :Mar, :Apr, :Jun, :Jul, :Aug, :Sep, :Oct, :Nov, :Dec;
- example: at :month1, :month2, :month3 ...
interval syntax
- every
- example: interval 1.month
scope syntax
- before
- example: before 2025
- between
- example: between 2025, 2026
- after
- examle: after 2023
148 149 150 151 152 153 154 |
# File 'lib/taskloop/task/task_property.rb', line 148 def month=(rule) unless rule.is_a?(SpecificRule) || rule.is_a?(ScopeRule) || rule.is_a?(IntervalRule) raise TypeError, "the rule of month must be SpecificRule or ScopeRule or IntervalRule" end @month = rule @month.unit = :month end |
#start_point ⇒ Object
305 306 307 |
# File 'lib/taskloop/task/task_property.rb', line 305 def start_point @start_point ||= DefaultRule.new(:full) end |
#start_point=(rule) ⇒ Object
StartPoint Property boundary syntax
- start_point
- example: from "2023-10-11 10:00:00"
297 298 299 300 301 302 303 |
# File 'lib/taskloop/task/task_property.rb', line 297 def start_point=(rule) unless rule.is_a?(StartPointBoundaryRule) raise TypeError, "the rule of start_point must be StartPointBoundaryRule" end @start_point = rule @start_point.unit = :full end |
#time ⇒ Object
269 270 271 |
# File 'lib/taskloop/task/task_property.rb', line 269 def time @time ||= DefaultRule.new(:time) end |
#time=(rule) ⇒ Object
Time Property time list syntax
- time
- example: time "10:10:30", "9:10:20", "20:10:20"
261 262 263 264 265 266 267 268 |
# File 'lib/taskloop/task/task_property.rb', line 261 def time=(rule) unless rule.is_a?(TimeListRule) raise TypeError, "the rule of time must be TimeListRule" end @time = rule @time.unit = :time end |
#week ⇒ Object
99 100 101 |
# File 'lib/taskloop/task/task_property.rb', line 99 def week @week ||= DefaultRule.new(:week) end |
#week=(rule) ⇒ Object
Week Property specific syntax
- at
- example: at :Mon, :Tue, :Fri
scope syntax
- before
- example: before :Mon
- between
- example: between :Mon, :Fri
- after
0 example: after :Tue
91 92 93 94 95 96 97 |
# File 'lib/taskloop/task/task_property.rb', line 91 def week=(rule) unless rule.is_a?(SpecificRule) || rule.is_a?(ScopeRule) raise TypeError, "the rule of week must be SpecificRule or ScopeRule or IntervalRule" end @week = rule @week.unit = :week end |
#year ⇒ Object
127 128 129 |
# File 'lib/taskloop/task/task_property.rb', line 127 def year @year ||= DefaultRule.new(:year) end |
#year=(rule) ⇒ Object
Year Property specific syntax
- of
- example: at 2024, 2025 ...
interval syntax
- interval
- example: interval 1.year
scope syntax
- before
- example: before 2025
- between
- example: between 2025, 2026
- after
- example: after 2023
119 120 121 122 123 124 125 |
# File 'lib/taskloop/task/task_property.rb', line 119 def year=(rule) unless rule.is_a?(SpecificRule) || rule.is_a?(ScopeRule) || rule.is_a?(IntervalRule) raise TypeError, "the rule of year must be SpecificRule or ScopeRule or IntervalRule" end @year = rule @year.unit = :year end |