Class: Eisenhower::Roadmap

Inherits:
Object
  • Object
show all
Defined in:
lib/eisenhower/roadmap.rb

Constant Summary collapse

BOOLEANS =
%w(archived public)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Roadmap

Returns a new instance of Roadmap.



7
8
9
# File 'lib/eisenhower/roadmap.rb', line 7

def initialize(attributes={})
  attributes.each { |key, val| send("#{key}=", val) if respond_to?("#{key}=") }
end

Instance Attribute Details

#app_idObject

Returns the value of attribute app_id.



3
4
5
# File 'lib/eisenhower/roadmap.rb', line 3

def app_id
  @app_id
end

#archivedObject

Returns the value of attribute archived.



3
4
5
# File 'lib/eisenhower/roadmap.rb', line 3

def archived
  @archived
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/eisenhower/roadmap.rb', line 3

def id
  @id
end

#publicObject

Returns the value of attribute public.



3
4
5
# File 'lib/eisenhower/roadmap.rb', line 3

def public
  @public
end

#staff_idsObject

Returns the value of attribute staff_ids.



3
4
5
# File 'lib/eisenhower/roadmap.rb', line 3

def staff_ids
  @staff_ids
end

#timeObject

Returns the value of attribute time.



3
4
5
# File 'lib/eisenhower/roadmap.rb', line 3

def time
  @time
end

#titleObject Also known as: name

Returns the value of attribute title.



3
4
5
# File 'lib/eisenhower/roadmap.rb', line 3

def title
  @title
end

Class Method Details

.allObject



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/eisenhower/roadmap.rb', line 41

def all
  return body = Eisenhower::Client.get_and_parse('/roadmap/listAll')
  #body.collect{|roadmap| Eisenhower::Roadmap.new({
  #  :id        => roadmap.last.last["_id"], 
  #  :app_id    => roadmap.last.last["appId"], 
  #  :archived  => roadmap.last.last["archived"],
  #  :public    => roadmap.last.last["public"],
  #  :title     => roadmap.last.last["title"],
  #  :time      => roadmap.last.last["time"],
  #  :staff_ids => roadmap.last.last["staff"].collect{|staff| staff["_id"]}
  #  }
  #)}
end

.find(app_id) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/eisenhower/roadmap.rb', line 55

def find(app_id)
  body = Eisenhower::Client.get_and_parse("/roadmap/get/id/#{app_id}")
  Eisenhower::Roadmap.new({
    :id        => body["_id"], 
    :app_id    => body["appId"], 
    :archived  => body["archived"],
    :public    => body["public"],
    :title     => body["title"],
    :staff_ids => body["staff"].collect{|staff| staff["_id"]}
  })
end

Instance Method Details

#roadsObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/eisenhower/roadmap.rb', line 21

def roads
  response = Eisenhower::Client.fetch("/roadmap/roads/id/#{self.id}")
  body = Crack::JSON.parse(response.body)["response"]
  body.collect{|road| Eisenhower::Road.new({
    :id               => road["_id"], 
    :title            => road["title"], 
    :description      => road["description"], 
    :description_html => road["descriptionHtml"], 
    :collapsed        => road["collapsed"], 
    :status           => road["status"]["status"], 
    :due              => road["due"] ? road["due"]["dmy"] : false,
    :started          => road["start"] ? road["start"]["dmy"] : false,
    :position         => road["order"]["position"], 
    :updates_count    => road["updatesCount"],
    :update_ids       => road["updates"].collect{|up| up["_id"]},
    :staff_ids        => road["staffList"]
  })}
end

#staffObject



17
18
19
# File 'lib/eisenhower/roadmap.rb', line 17

def staff
  self.staff_ids.collect{|id| Eisenhower::Staff.find(id) }
end