Class: ATM::List

Inherits:
Object show all
Defined in:
lib/atm/list.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ List

Returns a new instance of List.



14
15
16
# File 'lib/atm/list.rb', line 14

def initialize(obj)
  load_values obj
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/atm/list.rb', line 5

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/atm/list.rb', line 5

def name
  @name
end

#taskseriesObject (readonly)

Returns the value of attribute taskseries.



5
6
7
# File 'lib/atm/list.rb', line 5

def taskseries
  @taskseries
end

Class Method Details

.allObject



7
8
9
10
11
12
# File 'lib/atm/list.rb', line 7

def List.all
  lists = RTM.tasks.get_list.tasks.list.in_array
  lists.map do |l|
    List.new l
  end
end

Instance Method Details

#delete!Object



37
38
39
40
41
42
# File 'lib/atm/list.rb', line 37

def delete!
  @taskseries.each do |task|
    taskseries.delete!
  end
  RTM.lists.delete :list_id => :id
end

#load_values(obj) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/atm/list.rb', line 18

def load_values(obj)
  obj = Hashie::Mash.new obj
  @id = obj.id
  @name = obj.name
  @taskseries = obj.taskseries.in_array.map do |t|
    t.list = self
    Taskseries.new t
  end
end

#save!Object



28
29
30
31
32
33
34
35
# File 'lib/atm/list.rb', line 28

def save!
  if @id.nil?
    rsp = RTM.lists.add :name => name
    load_values rsp.list
  else
    throw NotImplementedError
  end
end