Class: TaskWarrior::Project
- Inherits:
-
Object
- Object
- TaskWarrior::Project
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/taskwarrior/project.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#tasks ⇒ Object
readonly
Returns the value of attribute tasks.
Instance Method Summary collapse
- #<<(task) ⇒ Object
-
#==(other) ⇒ Object
Projects are value objects.
- #hash ⇒ Object
-
#initialize(name, tasks = []) ⇒ Project
constructor
A new instance of Project.
- #to_s ⇒ Object
Constructor Details
#initialize(name, tasks = []) ⇒ Project
Returns a new instance of Project.
9 10 11 12 13 |
# File 'lib/taskwarrior/project.rb', line 9 def initialize(name, tasks = []) @name = name @tasks = tasks @tasks.each{|t| t.project = self} end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/taskwarrior/project.rb', line 3 def name @name end |
#tasks ⇒ Object (readonly)
Returns the value of attribute tasks.
3 4 5 |
# File 'lib/taskwarrior/project.rb', line 3 def tasks @tasks end |
Instance Method Details
#<<(task) ⇒ Object
15 16 17 18 |
# File 'lib/taskwarrior/project.rb', line 15 def <<(task) @tasks << task task.project = self end |
#==(other) ⇒ Object
Projects are value objects. They have no identity. If name and tasks are the same, the projects are identical.
30 31 32 33 |
# File 'lib/taskwarrior/project.rb', line 30 def ==(other) return false unless other.is_a?(Project) name.eql?(other.name) && tasks.eql?(other.tasks) end |
#hash ⇒ Object
24 25 26 |
# File 'lib/taskwarrior/project.rb', line 24 def hash name.hash + tasks.hash end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/taskwarrior/project.rb', line 20 def to_s "Project #{name} (#{@tasks.size} tasks)" end |