Class: Lingohub::Models::Projects
- Inherits:
-
Object
- Object
- Lingohub::Models::Projects
- Defined in:
- lib/lingohub/models/projects.rb
Constant Summary collapse
- PROJECT_URL =
'/projects'
Instance Method Summary collapse
- #[](project_title) ⇒ Object
- #all ⇒ Object
-
#initialize(client) ⇒ Projects
constructor
A new instance of Projects.
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 |
#all ⇒ Object
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 |