Top Level Namespace
Instance Method Summary collapse
Instance Method Details
#itunes_api_query(term) ⇒ Object
5 6 7 8 |
# File 'lib/nycda-itunes.rb', line 5 def itunes_api_query term term = URI.encode(term.gsub(' ','+')) Net::HTTP.get(URI("http://itunes.apple.com/search?term=#{term}&entity=song")) end |
#itunes_search(term) ⇒ Object
10 11 12 |
# File 'lib/nycda-itunes.rb', line 10 def itunes_search term JSON.parse(itunes_api_query term) end |
#process_itunes_data(data) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/nycda-itunes.rb', line 14 def process_itunes_data data # result = [] # data.each do |track| # result.push( { trackName: track["trackName"], # trackId: track["trackId"] } ) # end # result data.reduce([]) do |result,track| result.push({ trackName: track["trackName"], trackId: track["trackId"] }) end end |