Class: TaskWarrior::Annotation

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations, Validations
Defined in:
lib/taskwarrior/annotation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Validations

#entry_cannot_be_in_the_future, #must_be_date_or_nil

Constructor Details

#initialize(description = nil, entry = nil) ⇒ Annotation

Returns a new instance of Annotation.



14
15
16
17
# File 'lib/taskwarrior/annotation.rb', line 14

def initialize(description = nil, entry = nil)
  @description = description
  @entry = entry
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



5
6
7
# File 'lib/taskwarrior/annotation.rb', line 5

def description
  @description
end

#entryObject

Returns the value of attribute entry.



5
6
7
# File 'lib/taskwarrior/annotation.rb', line 5

def entry
  @entry
end

Instance Method Details

#==(other) ⇒ Object

Annotations are value objects. They have no identity. If entry date and description are the same, the annotations are identical.



29
30
31
32
# File 'lib/taskwarrior/annotation.rb', line 29

def ==(other)
  return false unless other.is_a?(Annotation)
  entry.eql?(other.entry) && description.eql?(other.description)
end

#hashObject



23
24
25
# File 'lib/taskwarrior/annotation.rb', line 23

def hash
  entry.hash + description.hash
end

#to_sObject



19
20
21
# File 'lib/taskwarrior/annotation.rb', line 19

def to_s
  "Annotation (#{entry}): #{description}"
end