Class: ATM::Taskseries

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ Taskseries

Returns a new instance of Taskseries.



13
14
15
# File 'lib/atm/taskseries.rb', line 13

def initialize(obj)
  load_values obj
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#listObject (readonly)

Returns the value of attribute list.



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

def list
  @list
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#tasksObject (readonly)

Returns the value of attribute tasks.



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

def tasks
  @tasks
end

Class Method Details

.allObject



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

def Taskseries.all
  List.all.inject([]) do |array, list|
    array.concat list.taskseries
  end
end

Instance Method Details

#delete!Object



39
40
41
42
43
# File 'lib/atm/taskseries.rb', line 39

def delete!
  tasks.each do |task|
    task.delete!
  end
end

#load_values(obj) ⇒ Object



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

def load_values(obj)
  obj = Hashie::Mash.new obj
  @id = obj.id
  @list = obj.list
  @name = obj.name
  @taskseries_id = obj.id
  @tasks = (obj.task || obj.tasks).in_array.map do |task|
    task.taskseries = self
    Task.new task
  end
end

#save!Object



29
30
31
32
33
34
35
36
37
# File 'lib/atm/taskseries.rb', line 29

def save!
  if @id.nil?
    rsp = RTM.tasks.add :name => name, :parse => 1
    load_values rsp.list.taskseries
  else
    throw NotImplementedError
  end
  self
end