Module: Tasks

Included in:
Things
Defined in:
lib/harvestthings/things/tasks.rb

Instance Method Summary collapse

Instance Method Details

#task_complete?(id) ⇒ Boolean

task_complete? - boolean of whether the task is complete

Parameters:

  • - (id)

    the task id

Returns:

  • (Boolean)
    • returns true of false



27
28
29
30
# File 'lib/harvestthings/things/tasks.rb', line 27

def task_complete?(id)
  task = @xml.search("object[@id='#{id}']")
  task.search("attribute[@name='datecompleted']").any?
end

#task_description(id) ⇒ String

task_description - grab formatted version of a task’s description

Parameters:

  • - (id)

    the tasks id

Returns:

  • (String)
    • a formatted string of the task description



17
18
19
20
21
# File 'lib/harvestthings/things/tasks.rb', line 17

def task_description(id)
  task = @xml.search("object[@id='#{id}']")
  title = task.search("attribute[@name='title']")
  clean(title.innerHTML.to_s)
end

#tasks(id) ⇒ Array

tasks - grab an array of the various task ids from the xml

Parameters:

  • - (id)

    the string of the project’s id

Returns:

  • (Array)
    • array of the various task ids



6
7
8
9
10
11
# File 'lib/harvestthings/things/tasks.rb', line 6

def tasks(id)
  project = @xml.search("object[@id='#{id}']")
  project.search("relationship[@name='children']") do |elem|
    return elem.attributes["idrefs"].to_s.split(" ")
  end
end