Class: FoldingAtHomeClient::Project
- Inherits:
-
Object
- Object
- FoldingAtHomeClient::Project
- Includes:
- Request
- Defined in:
- lib/folding_at_home_client/project.rb
Constant Summary
Constants included from Request
Request::API_URL, Request::HEADERS
Instance Attribute Summary collapse
-
#cause ⇒ Object
readonly
Returns the value of attribute cause.
-
#description_id ⇒ Object
readonly
Returns the value of attribute description_id.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#institution ⇒ Object
readonly
Returns the value of attribute institution.
-
#manager ⇒ Object
readonly
Returns the value of attribute manager.
-
#thumb ⇒ Object
readonly
Returns the value of attribute thumb.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #contributors ⇒ Object
- #description ⇒ Object
-
#initialize(id:, description: nil, manager: nil, cause: nil, modified: nil) ⇒ Project
constructor
A new instance of Project.
- #lookup ⇒ Object
Methods included from Request
#connection, #format_response, #request, #request_and_instantiate_objects, #request_unencoded
Constructor Details
#initialize(id:, description: nil, manager: nil, cause: nil, modified: nil) ⇒ Project
Returns a new instance of Project.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/folding_at_home_client/project.rb', line 17 def initialize( id:, description: nil, manager: nil, cause: nil, modified: nil ) @id = id @description_id = description if description @manager = Manager.new(name: manager) if manager @cause = cause if cause @updated_at = modified if modified end |
Instance Attribute Details
#cause ⇒ Object (readonly)
Returns the value of attribute cause.
7 8 9 |
# File 'lib/folding_at_home_client/project.rb', line 7 def cause @cause end |
#description_id ⇒ Object (readonly)
Returns the value of attribute description_id.
7 8 9 |
# File 'lib/folding_at_home_client/project.rb', line 7 def description_id @description_id end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
7 8 9 |
# File 'lib/folding_at_home_client/project.rb', line 7 def error @error end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/folding_at_home_client/project.rb', line 7 def id @id end |
#institution ⇒ Object (readonly)
Returns the value of attribute institution.
7 8 9 |
# File 'lib/folding_at_home_client/project.rb', line 7 def institution @institution end |
#manager ⇒ Object (readonly)
Returns the value of attribute manager.
7 8 9 |
# File 'lib/folding_at_home_client/project.rb', line 7 def manager @manager end |
#thumb ⇒ Object (readonly)
Returns the value of attribute thumb.
7 8 9 |
# File 'lib/folding_at_home_client/project.rb', line 7 def thumb @thumb end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
7 8 9 |
# File 'lib/folding_at_home_client/project.rb', line 7 def updated_at @updated_at end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/folding_at_home_client/project.rb', line 7 def url @url end |
Instance Method Details
#contributors ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/folding_at_home_client/project.rb', line 55 def contributors endpoint = '/project/contributors' params = { projects: @id } request(endpoint:, params:).map do |name| User.new(name:) end end |
#description ⇒ Object
64 65 66 |
# File 'lib/folding_at_home_client/project.rb', line 64 def description Description.new(id: @description_id).lookup end |
#lookup ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/folding_at_home_client/project.rb', line 32 def lookup endpoint = "/project/#{@id}" project_hash = request(endpoint:).first error = project_hash[:error] if error @error = error return self end @body = project_hash[:description] @manager = Manager.new( name: project_hash[:manager], thumb: project_hash[:mthumb], description: project_hash[:mdescription] ) @cause = project_hash[:cause] @updated_at = project_hash[:modified] self end |