Class: Todoly

Inherits:
Object
  • Object
show all
Defined in:
lib/todoly.rb,
lib/todoly/task.rb,
lib/todoly/filter.rb,
lib/todoly/project.rb,
lib/todoly/rest_interface.rb

Defined Under Namespace

Classes: Filter, Project, RestInterface, Task, TodolyError

Constant Summary collapse

TODOLY_API_URL =
"https://todo.ly/api/"

Instance Method Summary collapse

Constructor Details

#initialize(opt = {}) ⇒ Todoly

Returns a new instance of Todoly.



8
9
10
11
12
13
# File 'lib/todoly.rb', line 8

def initialize(opt={})
  @rest_if = RestInterface.new(opt)
  @projects = nil
  @filters = nil
  @tasks = nil
end

Instance Method Details

#filtersObject



23
24
25
# File 'lib/todoly.rb', line 23

def filters
  @filters ||= Filter.list(@rest_if)
end

#find_filters(name) ⇒ Object



27
28
29
# File 'lib/todoly.rb', line 27

def find_filters(name)
  filters().find{|f| name === f.name }
end

#find_project(name) ⇒ Object



19
20
21
# File 'lib/todoly.rb', line 19

def find_project(name)
  projects().find{|prj| name === prj.name }
end

#find_task(name) ⇒ Object



35
36
37
# File 'lib/todoly.rb', line 35

def find_task(name)
  tasks().find{|t| name === t.name }
end

#new_task(str, project = nil) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/todoly.rb', line 39

def new_task(str, project = nil)
  obj = {}
  if project
    obj["ProjectId"] = project.id
  end
  t = Task.create(@rest_if, str, obj)
  @tasks << t if @tasks
  t
end

#projectsObject



15
16
17
# File 'lib/todoly.rb', line 15

def projects
  @projects ||= Project.list(@rest_if)
end

#tasksObject



31
32
33
# File 'lib/todoly.rb', line 31

def tasks
  @tasks ||= Task.list(@rest_if)
end