Class: Pandoru::Models::GenreStationList
- Inherits:
-
Collection
- Object
- Base
- Collection
- Pandoru::Models::GenreStationList
- Defined in:
- lib/pandoru/models/station.rb
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Collection
#<<, #[], #each, #empty?, #first, #initialize, #last, #length, #to_a
Methods inherited from Base
date_field, field, fields, from_json_list, #initialize, #inspect, #populate_from_json, #to_h
Constructor Details
This class inherits a constructor from Pandoru::Models::Collection
Class Method Details
.from_json(api_client, data) ⇒ Object
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/pandoru/models/station.rb', line 220 def self.from_json(api_client, data) instance = new(data, api_client) instance.populate_from_json(data) if data['categories'] data['categories'].each do |category| category_name = category['categoryName'] next unless category['stations'] category['stations'].each do |station_data| station_data['categoryName'] = category_name station = GenreStation.from_json(api_client, station_data) instance << station end end end instance end |
Instance Method Details
#categories ⇒ Object
240 241 242 |
# File 'lib/pandoru/models/station.rb', line 240 def categories map(&:category).uniq end |
#stations_for_category(category) ⇒ Object
244 245 246 |
# File 'lib/pandoru/models/station.rb', line 244 def stations_for_category(category) select { |station| station.category == category } end |