Class: Cartola::Team

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

Class Method Summary collapse

Class Method Details

.find(id) ⇒ Object



8
9
10
11
12
# File 'lib/cartola/team.rb', line 8

def self.find(id)
  response = RestClient.get 'https://api.cartolafc.globo.com/clubes'
  json = JSON.parse response.body
  from_source(json[id.to_s])
end

.find_allObject



22
23
24
25
26
# File 'lib/cartola/team.rb', line 22

def self.find_all
  response = RestClient.get 'https://api.cartolafc.globo.com/clubes'
  json = JSON.parse response.body
  from_source(json.values)
end

.find_by_abbreviation(abbreviation) ⇒ Object



18
19
20
# File 'lib/cartola/team.rb', line 18

def self.find_by_abbreviation(abbreviation)
  self.find_all.select{ |t| t.abreviacao == abbreviation }
end

.find_by_name(name) ⇒ Object



14
15
16
# File 'lib/cartola/team.rb', line 14

def self.find_by_name(name)
  self.find_all.find{ |t| t.nome == name }
end