Class: Todoly::Project

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rest_if, obj) ⇒ Project

Returns a new instance of Project.



13
14
15
16
17
18
# File 'lib/todoly/project.rb', line 13

def initialize(rest_if, obj)
  @rest_if = rest_if
  @raw = obj
  @id = obj["Id"]
  @name = obj["Content"]
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



20
21
22
# File 'lib/todoly/project.rb', line 20

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



20
21
22
# File 'lib/todoly/project.rb', line 20

def name
  @name
end

#rawObject (readonly)

Returns the value of attribute raw.



20
21
22
# File 'lib/todoly/project.rb', line 20

def raw
  @raw
end

Class Method Details

.list(rest_if) ⇒ Object



7
8
9
10
11
# File 'lib/todoly/project.rb', line 7

def self.list(rest_if)
  rest_if.projects.map do |obj|
    self.new(rest_if, obj)
  end
end

Instance Method Details

#[](key) ⇒ Object



22
23
24
# File 'lib/todoly/project.rb', line 22

def [](key)
  @raw[key]
end

#done_tasksObject



32
33
34
35
36
# File 'lib/todoly/project.rb', line 32

def done_tasks
  @rest_if.done_items_of_project(@id).map do |item|
    Task.new(@rest_if, item)
  end
end

#tasksObject



26
27
28
29
30
# File 'lib/todoly/project.rb', line 26

def tasks
  @rest_if.items_of_project(@id).map do |item|
    Task.new(@rest_if, item)
  end
end