Class: TaskWarrior::Task
- Inherits:
-
Object
- Object
- TaskWarrior::Task
- Includes:
- ActiveModel::Validations, Attributes, Validations
- Defined in:
- lib/taskwarrior/task.rb
Instance Method Summary collapse
-
#==(other) ⇒ Object
Tasks are entity objects.
-
#eql?(other) ⇒ Boolean
other may have the same uuid, but if its attributes differ, it will not be equal.
- #hash ⇒ Object
-
#initialize(description) ⇒ Task
constructor
A new instance of Task.
- #to_s ⇒ Object
Methods included from Validations
#entry_cannot_be_in_the_future, #must_be_date_or_nil
Methods included from Attributes
Constructor Details
#initialize(description) ⇒ Task
Returns a new instance of Task.
40 41 42 43 44 45 46 47 |
# File 'lib/taskwarrior/task.rb', line 40 def initialize(description) @description = description @dependencies = [] @children = [] @tags = [] @annotations = [] @uuid = SecureRandom.uuid end |
Instance Method Details
#==(other) ⇒ Object
Tasks are entity objects. They have their identity defined by the uuid. If the uuids are the same, the tasks are identical.
66 67 68 69 |
# File 'lib/taskwarrior/task.rb', line 66 def ==(other) return false unless other.is_a?(Task) uuid == other.uuid end |
#eql?(other) ⇒ Boolean
other may have the same uuid, but if its attributes differ, it will not be equal
54 55 56 57 58 |
# File 'lib/taskwarrior/task.rb', line 54 def eql?(other) self.class.attributes.each do |attr| return false unless send(attr).eql?(other.send(attr)) end end |
#hash ⇒ Object
60 61 62 |
# File 'lib/taskwarrior/task.rb', line 60 def hash uuid.hash end |
#to_s ⇒ Object
49 50 51 |
# File 'lib/taskwarrior/task.rb', line 49 def to_s "Task '#{description}'".yield_self { |result| "#{result} <#{uuid}>" if uuid } end |