Class: Team
- Inherits:
-
Object
- Object
- Team
- Defined in:
- lib/models/team.rb
Instance Attribute Summary collapse
-
#folders ⇒ Object
readonly
Returns the value of attribute folders.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #folder_by_name(name) ⇒ Object
-
#initialize(name: nil, folders: nil, id: nil) ⇒ Team
constructor
A new instance of Team.
- #render_list ⇒ Object
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
#folders ⇒ Object (readonly)
Returns the value of attribute folders.
4 5 6 |
# File 'lib/models/team.rb', line 4 def folders @folders end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/models/team.rb', line 4 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/models/team.rb', line 4 def name @name end |
Class Method Details
.all ⇒ Object
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_list ⇒ Object
12 13 14 |
# File 'lib/models/team.rb', line 12 def render_list TeamPresenter.render_list(self) end |