Class: FoldingAtHomeClient::Manager

Inherits:
Object
  • Object
show all
Includes:
Request
Defined in:
lib/folding_at_home_client/manager.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: nil, name: nil, description: nil, thumb: nil, url: nil, institution: nil) ⇒ Manager

Returns a new instance of Manager.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/folding_at_home_client/manager.rb', line 15

def initialize(
  id: nil,
  name: nil,
  description: nil,
  thumb: nil,
  url: nil,
  institution: nil
)
  @id = id if id

  @name = name if name
  @description = description if description
  @thumb = thumb if thumb && !thumb.empty?
  @url = url if url && !url.empty?
  @institution = institution if institution && !institution.empty?
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



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

def description
  @description
end

#errorObject (readonly)

Returns the value of attribute error.



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

def error
  @error
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#institutionObject (readonly)

Returns the value of attribute institution.



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

def institution
  @institution
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#thumbObject (readonly)

Returns the value of attribute thumb.



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

def thumb
  @thumb
end

#urlObject (readonly)

Returns the value of attribute url.



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

def url
  @url
end

Instance Method Details

#lookupObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/folding_at_home_client/manager.rb', line 32

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

  error = manager_hash[:error]

  if error
    @error = error
    return self
  end

  @name = manager_hash[:name]
  @description = manager_hash[:description]

  thumb = manager_hash[:thumb]
  @thumb = thumb if thumb && !thumb.empty?

  url = manager_hash[:url]
  @url = url if url && !url.empty?

  institution = manager_hash[:institution]
  @institution = institution if institution && !institution.empty?

  self
end