Class: Rumember::Task

Inherits:
Abstract show all
Defined in:
lib/rumember/task.rb

Instance Attribute Summary

Attributes inherited from Abstract

#parent

Instance Method Summary collapse

Methods inherited from Abstract

boolean_reader, #initialize, integer_reader, reader, time_reader

Methods included from Dispatcher

#dispatch, #lists, #locations

Constructor Details

This class inherits a constructor from Rumember::Abstract

Instance Method Details

#add_tags(tags) ⇒ Object



62
63
64
# File 'lib/rumember/task.rb', line 62

def add_tags(tags)
  transaction_dispatch('tasks.addTags', 'tags' => tags)
end

#completeObject



50
51
52
# File 'lib/rumember/task.rb', line 50

def complete
  transaction_dispatch('tasks.complete')
end

#completed?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/rumember/task.rb', line 12

def completed?
  !(@attributes['task']['completed'].empty?)
end

#deleteObject



46
47
48
# File 'lib/rumember/task.rb', line 46

def delete
  transaction_dispatch('tasks.delete')
end

#deleted?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/rumember/task.rb', line 16

def deleted?
  !(@attributes['task']['completed'].empty?)
end

#lower_priorityObject



74
75
76
# File 'lib/rumember/task.rb', line 74

def lower_priority
  transaction_dispatch('tasks.movePriority', 'direction' => 'down')
end

#move_to(list) ⇒ Object



78
79
80
81
82
83
84
85
86
# File 'lib/rumember/task.rb', line 78

def move_to(list)
  transaction_dispatch(
    'tasks.moveTo',
    'from_list_id' => parent.id,
    'to_list_id' => list.id
  ).tap do
    @parent = list
  end
end

#paramsObject



36
37
38
# File 'lib/rumember/task.rb', line 36

def params
  {'taskseries_id' => taskseries_id, 'task_id' => task_id}
end

#postponeObject



58
59
60
# File 'lib/rumember/task.rb', line 58

def postpone
  transaction_dispatch('tasks.postpone')
end

#postponedObject



20
21
22
# File 'lib/rumember/task.rb', line 20

def postponed
  Integer(@attributes['task']['postponed'])
end

#priorityObject



24
25
26
# File 'lib/rumember/task.rb', line 24

def priority
  @attributes['task']['priority'] == "N" ? 0 : Integer(@attributes['task']['priority'])
end

#raise_priorityObject



70
71
72
# File 'lib/rumember/task.rb', line 70

def raise_priority
  transaction_dispatch('tasks.movePriority', 'direction' => 'up')
end

#remove_tags(tags) ⇒ Object



66
67
68
# File 'lib/rumember/task.rb', line 66

def remove_tags(tags)
  transaction_dispatch('tasks.removeTags', 'tags' => tags)
end

#set_due_date(url) ⇒ Object Also known as: due_date=



100
101
102
# File 'lib/rumember/task.rb', line 100

def set_due_date(url)
  transaction_dispatch('tasks.setDueDate', 'url' => url)
end

#set_location(id) ⇒ Object Also known as: location=



105
106
107
108
# File 'lib/rumember/task.rb', line 105

def set_location(id)
  id = id.location_id if id.respond_to?(:location_id)
  transaction_dispatch('tasks.setLocation', id)
end

#set_tags(tags) ⇒ Object Also known as: tags=



95
96
97
# File 'lib/rumember/task.rb', line 95

def set_tags(tags)
  transaction_dispatch('tasks.setTags', 'tags' => Array(tags).join(' '))
end

#tagsObject



28
29
30
31
32
33
34
# File 'lib/rumember/task.rb', line 28

def tags
  if @attributes['tags'].empty?
    []
  else
    Array(@attributes['tags']['tag'])
  end
end

#task_idObject



8
9
10
# File 'lib/rumember/task.rb', line 8

def task_id
  Integer(@attributes['task']['id'])
end

#transaction_dispatch(*args) ⇒ Object



40
41
42
43
44
# File 'lib/rumember/task.rb', line 40

def transaction_dispatch(*args)
  super(*args) do |response|
    @attributes = response['list']['taskseries']
  end
end

#uncompleteObject



54
55
56
# File 'lib/rumember/task.rb', line 54

def uncomplete
  transaction_dispatch('tasks.uncomplete')
end