Class: Dobedobedo::Workspace

Inherits:
Object
  • Object
show all
Defined in:
lib/dobedobedo/workspace.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token, h = {}) ⇒ Workspace

Returns a new instance of Workspace.



5
6
7
8
9
10
11
12
13
# File 'lib/dobedobedo/workspace.rb', line 5

def initialize(token, h={})
  @token = token
  unless h.nil?
    h.each do |k,v|
      Workspace.send(:attr_accessor, k.to_sym)
      self.send("#{k}=".to_sym, v)
    end
  end
end

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



3
4
5
# File 'lib/dobedobedo/workspace.rb', line 3

def token
  @token
end

Instance Method Details

#alertsObject



31
32
33
# File 'lib/dobedobedo/workspace.rb', line 31

def alerts
  @token.get("/workspaces/#{@id}/alerts").parsed.map {|a| Dobedobedo::Alert.new(@token, a)}
end

#find_project_by_name(name) ⇒ Object



19
20
21
# File 'lib/dobedobedo/workspace.rb', line 19

def find_project_by_name(name)
  projects.select {|x| x.name == name}.first
end

#notesObject



27
28
29
# File 'lib/dobedobedo/workspace.rb', line 27

def notes
  @token.get("/workspaces/#{@id}/notes").parsed.map {|n| Dobedobedo::Note.new(@token, @id, n)}
end

#projectsObject



15
16
17
# File 'lib/dobedobedo/workspace.rb', line 15

def projects
  @token.get("/workspaces/#{@id}/projects").parsed.map {|p| Dobedobedo::Project.new(@token, @id, p)}
end

#tasksObject



23
24
25
# File 'lib/dobedobedo/workspace.rb', line 23

def tasks
  @token.get("/workspaces/#{@id}/tasks/").parsed.map {|t| Dobedobedo::Task.new(@token, @id, nil, t)}
end

#usersObject



35
36
37
# File 'lib/dobedobedo/workspace.rb', line 35

def users
  @token.get("/workspaces/#{@id}/users").parsed.map {|u| Dobedobedo::User.new(@token, @id, u)}	
end