module Doing::ItemState

State queries for a Doing entry

Public Instance Methods

finished?() click to toggle source

Test if item has a @done tag

@return [Boolean] true item has @done tag

# File lib/doing/item/state.rb, line 9
def finished?
  tags?('done')
end
should_finish?() click to toggle source

Test if item is included in never_finish config and thus should not receive a @done tag

@return [Boolean] item should receive @done tag

# File lib/doing/item/state.rb, line 28
def should_finish?
  should?('never_finish')
end
should_time?() click to toggle source

Test if item is included in never_time config and thus should not receive a date on the @done tag

@return [Boolean] item should receive @done date

# File lib/doing/item/state.rb, line 38
def should_time?
  should?('never_time')
end
unfinished?() click to toggle source

Test if item does not contain @done tag

@return [Boolean] true if item is missing @done tag

# File lib/doing/item/state.rb, line 18
def unfinished?
  tags?('done', negate: true)
end

Private Instance Methods

should?(key) click to toggle source
# File lib/doing/item/state.rb, line 44
def should?(key)
  config = Doing.settings
  return true unless config[key].is_a?(Array)

  config[key].each do |tag|
    next if tag.nil?

    if tag =~ /^@/
      return false if tags?(tag.sub(/^@/, '').downcase)
    elsif section&.downcase == tag.downcase
      return false
    end
  end

  true
end