Class: Taskpaper::Task

Inherits:
Item
  • Object
show all
Defined in:
lib/taskpaper/task.rb

Instance Attribute Summary

Attributes inherited from Item

#description, #level

Instance Method Summary collapse

Methods inherited from Item

#classify, #inspect, #project_regex, #tag_regex, #tags, #task_regex, #to_s, #untagged_description

Constructor Details

#initialize(string) ⇒ Task

Returns a new instance of Task.



3
4
5
# File 'lib/taskpaper/task.rb', line 3

def initialize(string)
  @description = string
end

Instance Method Details

#complete!(polarity = nil, time = Time.now) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/taskpaper/task.rb', line 7

def complete!(polarity=nil,time=Time.now)
  if !polarity.nil?
    if polarity == false
      # Set to incomplete
      description.gsub!(/^x/, '-')
      remove_done_tags
    else
      # Set to complete with @done(TIME)
      description.gsub!(/^.\s/, 'x ')
      remove_done_tags
      description.strip!
      description << " @done(#{time})"
    end
    description.strip!
    description
  else
    # Polarity unspecified so.... REVERSE POLARITY!!!!
    complete!(!complete?)
  end
end

#complete=(time) ⇒ Object



28
29
30
# File 'lib/taskpaper/task.rb', line 28

def complete=(time)
  completed_at(time)
end

#complete?Boolean Also known as: complete

Returns:

  • (Boolean)


37
38
39
# File 'lib/taskpaper/task.rb', line 37

def complete?
  begins_with_x? || tagged_done?
end

#completed_at(time) ⇒ Object Also known as: complete_at



32
33
34
# File 'lib/taskpaper/task.rb', line 32

def completed_at(time)
  complete!(true, time)
end