Class: Lingohub::Models::Projects

Inherits:
Object
  • Object
show all
Defined in:
lib/lingohub/models/projects.rb

Constant Summary collapse

PROJECT_URL =
'/projects'

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Projects

Returns a new instance of Projects.



9
10
11
# File 'lib/lingohub/models/projects.rb', line 9

def initialize(client)
  @client   = client
end

Instance Method Details

#[](project_title) ⇒ Object



24
25
26
# File 'lib/lingohub/models/projects.rb', line 24

def [](project_title)
  return all[project_title]
end

#allObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/lingohub/models/projects.rb', line 13

def all
  return @projects if defined? @projects
  @projects = {}
  response = JSON.parse @client.get(PROJECT_URL).to_s
  response["members"].each do |member|
    project = Lingohub::Models::Project.new(@client, member["links"][0]["href"])
    @projects[member["title"]] = project
  end
  @projects
end