Sha256: f327230bbe518ab7c57cd483721a2d697c06db6037cd4edc439d4f3e2f83676e

Contents?: true

Size: 687 Bytes

Versions: 3

Compression:

Stored size: 687 Bytes

Contents

module Cartola
  class Team < RestModel
    id
    properties :nome,
               :abreviacao,
               :posicao

    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

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

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cartola-0.1.4 lib/cartola/team.rb
cartola-0.1.3 lib/cartola/team.rb
cartola-0.1.2 lib/cartola/team.rb