Class: Task
- Inherits:
-
Object
- Object
- Task
- Defined in:
- lib/day/task.rb
Overview
DayRB Task Class
Has essentially only one function, which is to perform valid_today? checks. But maybe we’ll just keep it and give it more responsibility later.
MIT License; See LICENSE file; Cameron Carroll 2014
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#fulfillment ⇒ Object
readonly
Returns the value of attribute fulfillment.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#time_estimate ⇒ Object
readonly
Returns the value of attribute time_estimate.
-
#valid_days ⇒ Object
readonly
Returns the value of attribute valid_days.
Instance Method Summary collapse
-
#initialize(name, description, valid_days, time_estimate, fulfillment) ⇒ Task
constructor
A new instance of Task.
-
#valid_today? ⇒ Boolean
Determine whether the task is valid today.
Constructor Details
#initialize(name, description, valid_days, time_estimate, fulfillment) ⇒ Task
Returns a new instance of Task.
12 13 14 15 16 17 18 |
# File 'lib/day/task.rb', line 12 def initialize(name, description, valid_days, time_estimate, fulfillment) @name = name @valid_days = valid_days @description = description @time_estimate = time_estimate @fulfillment = fulfillment end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
10 11 12 |
# File 'lib/day/task.rb', line 10 def description @description end |
#fulfillment ⇒ Object (readonly)
Returns the value of attribute fulfillment.
10 11 12 |
# File 'lib/day/task.rb', line 10 def fulfillment @fulfillment end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/day/task.rb', line 10 def name @name end |
#time_estimate ⇒ Object (readonly)
Returns the value of attribute time_estimate.
10 11 12 |
# File 'lib/day/task.rb', line 10 def time_estimate @time_estimate end |
#valid_days ⇒ Object (readonly)
Returns the value of attribute valid_days.
10 11 12 |
# File 'lib/day/task.rb', line 10 def valid_days @valid_days end |
Instance Method Details
#valid_today? ⇒ Boolean
Determine whether the task is valid today.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/day/task.rb', line 21 def valid_today? if @valid_days today = Time.new.wday #0 is sunday, 6 saturday weekday_key = case today when 0 then :sunday when 1 then :monday when 2 then :tuesday when 3 then :wednesday when 4 then :thursday when 5 then :friday when 6 then :saturday end if (@valid_days.include?(weekday_key) || @valid_days.empty?) return true else return false end else return true # valid everyday end end |