Class: Clear

Inherits:
Object
  • Object
show all
Defined in:
lib/clear.rb

Instance Method Summary collapse

Constructor Details

#initializeClear

Returns a new instance of Clear.



8
9
10
11
# File 'lib/clear.rb', line 8

def initialize
  @@db = nil
  @@lists = []
end

Instance Method Details

#dbObject



57
58
59
# File 'lib/clear.rb', line 57

def db
  @@db
end

#list_tasksObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/clear.rb', line 13

def list_tasks
  retrieve_lists
  puts

  @@lists.each do |list|
    next if list.tasks.size == 0

    puts " " + "#{list.title}".red.bold
    list.tasks.each do |task|
      puts " [#{task.id.to_s}] ".cyan + task.title
    end
    puts
  end
end

#listsObject



53
54
55
# File 'lib/clear.rb', line 53

def lists
  @@lists || []
end

#retrieve_listsObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/clear.rb', line 28

def retrieve_lists
  @@lists = []

  connection.lists do |row|
    list = List.new
    list.id = row["id"]
    list.identifier = row["identifier"]
    list.title = row["title"]
    list.tasks = []

    retrieve_tasks(list)
    @@lists << list
  end
end

#retrieve_tasks(list) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/clear.rb', line 43

def retrieve_tasks(list)
  connection.tasks(list) do |row|
    task = Task.new
    task.id = row["id"]
    task.title = row["title"]

    list.tasks << task
  end
end