Class: Rumember::List

Inherits:
Abstract show all
Defined in:
lib/rumember/list.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, #transaction_dispatch

Constructor Details

This class inherits a constructor from Rumember::Abstract

Instance Method Details

#paramsObject



9
10
11
# File 'lib/rumember/list.rb', line 9

def params
  {'list_id' => id}
end

#tasks(params = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rumember/list.rb', line 13

def tasks(params = {})
  list = dispatch('tasks.getList', params)['tasks']['list']
  if list.kind_of?(Array)
    list.flat_map do |l|
      ll = List.new(@parent, {'id' => l['id']})
      (l['taskseries'].kind_of?(Array) ? l['taskseries'] : [l['taskseries']]).map do |t|
        Task.new(ll, t)
      end
    end
  else
    if list.has_key?('taskseries')
      (list['taskseries'].kind_of?(Array) ? list['taskseries'] : [list['taskseries']]).map do |t|
        Task.new(self, t)
      end
    else
      []
    end
  end
end