Class: Linguist::Models::Projects
- Inherits:
-
Object
- Object
- Linguist::Models::Projects
- Defined in:
- lib/linguist_ruby/models/projects.rb
Constant Summary collapse
- PROJECT_URL =
'/projects'
Instance Method Summary collapse
- #[](project_title) ⇒ Object
- #all ⇒ Object
- #create(title) ⇒ 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/linguist_ruby/models/projects.rb', line 9 def initialize(client) @client = client end |
Instance Method Details
#[](project_title) ⇒ Object
28 29 30 |
# File 'lib/linguist_ruby/models/projects.rb', line 28 def [](project_title) return all[project_title] end |
#all ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/linguist_ruby/models/projects.rb', line 17 def all return @projects if defined? @projects @projects = {} response = JSON.parse @client.get(PROJECT_URL).to_s response["projects"]["members"].each do |member| project = Linguist::Models::Project.new(@client, member["link"][0]["href"]) @projects[member["title"]] = project end @projects end |
#create(title) ⇒ Object
13 14 15 |
# File 'lib/linguist_ruby/models/projects.rb', line 13 def create(title) @client.post(PROJECT_URL, :project => {:title => title}) end |