Class: Wunderlist::List

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, inbox = nil, api = nil) ⇒ List

Returns a new instance of List.



28
29
30
31
32
# File 'lib/wunderlist/list.rb', line 28

def initialize(name = nil, inbox = nil, api = nil)
  @name = name
  @inbox = inbox
  @api = api
end

Instance Attribute Details

#apiObject

Returns the value of attribute api.



26
27
28
# File 'lib/wunderlist/list.rb', line 26

def api
  @api
end

#idObject

Returns the value of attribute id.



26
27
28
# File 'lib/wunderlist/list.rb', line 26

def id
  @id
end

#inboxObject

Returns the value of attribute inbox.



26
27
28
# File 'lib/wunderlist/list.rb', line 26

def inbox
  @inbox
end

#nameObject

Returns the value of attribute name.



26
27
28
# File 'lib/wunderlist/list.rb', line 26

def name
  @name
end

#sharedObject

Returns the value of attribute shared.



26
27
28
# File 'lib/wunderlist/list.rb', line 26

def shared
  @shared
end

Instance Method Details

#create_task(name, date = nil) ⇒ Object



39
40
41
# File 'lib/wunderlist/list.rb', line 39

def create_task(name, date = nil)
  Wunderlist::Task.new(name, date, self, @api).save
end

#destroy(api = nil) ⇒ Object



54
55
56
57
# File 'lib/wunderlist/list.rb', line 54

def destroy(api = nil)
  @api ||= api
  @api.destroy(self)
end

#flushObject



59
60
61
# File 'lib/wunderlist/list.rb', line 59

def flush
  @tasks = nil
end

#save(api = nil) ⇒ Object



49
50
51
52
# File 'lib/wunderlist/list.rb', line 49

def save(api = nil)
  @api ||= api
  @api.save(self)
end

#tasksObject



34
35
36
37
# File 'lib/wunderlist/list.rb', line 34

def tasks
  @tasks = @api.tasks self if @tasks == nil
  @tasks
end

#todayObject



43
44
45
46
47
# File 'lib/wunderlist/list.rb', line 43

def today
  tasks.clone.keep_if do |t|
    t.date == Date.today
  end
end