Class: Team

Inherits:
Object
  • Object
show all
Defined in:
lib/models/team.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name: nil, folders: nil, id: nil) ⇒ Team

Returns a new instance of Team.



6
7
8
9
10
# File 'lib/models/team.rb', line 6

def initialize(name: nil, folders: nil, id: nil)
  @name = name
  @folders = folders
  @id = id
end

Instance Attribute Details

#foldersObject (readonly)

Returns the value of attribute folders.



4
5
6
# File 'lib/models/team.rb', line 4

def folders
  @folders
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/models/team.rb', line 4

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/models/team.rb', line 4

def name
  @name
end

Class Method Details

.allObject



23
24
25
26
27
28
29
# File 'lib/models/team.rb', line 23

def all
  cryptopus_adapter = CryptopusAdapter.new
  response = JSON.parse(cryptopus_adapter.get('teams'), symbolize_names: true)
  response[:data].map do |team|
    TeamSerializer.from_json(team.to_json, folders_json: included_folders(response))
  end
end

.find_by_name(name) ⇒ Object



31
32
33
34
35
# File 'lib/models/team.rb', line 31

def find_by_name(name)
  Team.all.find do |team|
    team.name.downcase.gsub(' ', '-') == name.downcase
  end
end

Instance Method Details

#folder_by_name(name) ⇒ Object



16
17
18
19
20
# File 'lib/models/team.rb', line 16

def folder_by_name(name)
  folders.find do |folder|
    folder.name.downcase.gsub(' ', '-') == name.downcase
  end
end

#render_listObject



12
13
14
# File 'lib/models/team.rb', line 12

def render_list
  TeamPresenter.render_list(self)
end