Sha256: 123b3de2059909b71736ac5650d9d50c36b05a8651ab791e504551fc8e1e8072

Contents?: true

Size: 845 Bytes

Versions: 3

Compression:

Stored size: 845 Bytes

Contents

# frozen_string_literal: true

module TaskWarrior
  class Annotation
    attr_accessor :entry, :description

    include ActiveModel::Validations
    validates :entry, presence: true
    validates :description, presence: true

    include TaskWarrior::Validations
    validate :entry_cannot_be_in_the_future

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

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

    def hash
      entry.hash + description.hash
    end

    # Annotations are value objects. They have no identity.
    # If entry date and description are the same, the annotations are identical.
    def ==(other)
      return false unless other.is_a?(Annotation)
      entry.eql?(other.entry) && description.eql?(other.description)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
taskwarrior-1.0.2 lib/taskwarrior/annotation.rb
taskwarrior-1.0.1 lib/taskwarrior/annotation.rb
taskwarrior-1.0.0 lib/taskwarrior/annotation.rb