Class: FoldingAtHomeClient::Description

Inherits:
Object
  • Object
show all
Includes:
Request
Defined in:
lib/folding_at_home_client/description.rb

Constant Summary

Constants included from Request

Request::API_URL, Request::HEADERS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Request

#connection, #format_response, #request, #request_and_instantiate_objects, #request_unencoded

Constructor Details

#initialize(id:, description: nil, manager: nil, projects: nil, modified: nil) ⇒ Description

Returns a new instance of Description.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/folding_at_home_client/description.rb', line 13

def initialize(
  id:,
  description: nil,
  manager: nil,
  projects: nil,
  modified: nil
)
  @id = id

  @body = description if description
  @manager = manager if manager
  @projects = projects if projects
  @updated_at = modified if modified
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



7
8
9
# File 'lib/folding_at_home_client/description.rb', line 7

def body
  @body
end

#errorObject (readonly)

Returns the value of attribute error.



7
8
9
# File 'lib/folding_at_home_client/description.rb', line 7

def error
  @error
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/folding_at_home_client/description.rb', line 7

def id
  @id
end

#managerObject (readonly)

Returns the value of attribute manager.



7
8
9
# File 'lib/folding_at_home_client/description.rb', line 7

def manager
  @manager
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



7
8
9
# File 'lib/folding_at_home_client/description.rb', line 7

def updated_at
  @updated_at
end

Instance Method Details

#lookupObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/folding_at_home_client/description.rb', line 28

def lookup
  endpoint = "/project/description/#{id}"
  description_hash = request(endpoint:).first

  error = description_hash[:error]

  if error
    @error = error
    return self
  end

  @body = description_hash[:description]
  @manager = description_hash[:manager]
  @updated_at = description_hash[:modified]

  self
end