Class: MLB::Divisions
- Inherits:
-
Shale::Mapper
- Object
- Shale::Mapper
- MLB::Divisions
- Defined in:
- lib/mlb/divisions.rb
Class Method Summary collapse
Class Method Details
.all(sport: Sport.new(id: 1)) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/mlb/divisions.rb', line 11 def self.all(sport: Sport.new(id: 1)) sport_id = sport.respond_to?(:id) ? sport.id : sport params = {sportId: sport_id} query_string = URI.encode_www_form(params) response = CLIENT.get("divisions?#{query_string}") divisions = from_json(response) divisions.divisions.sort! end |
.find(division, sport: Sport.new(id: 1)) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/mlb/divisions.rb', line 20 def self.find(division, sport: Sport.new(id: 1)) id = division.respond_to?(:id) ? division.id : division sport_id = sport.respond_to?(:id) ? sport.id : sport params = {sportId: sport_id} query_string = URI.encode_www_form(params) response = CLIENT.get("divisions/#{id}?#{query_string}") divisions = from_json(response) divisions.divisions.first end |