Class: TunesPI::Tuner
- Inherits:
-
Object
- Object
- TunesPI::Tuner
- Defined in:
- lib/tunespi.rb
Instance Attribute Summary collapse
-
#search ⇒ Object
sets definable attribute for search term.
Instance Method Summary collapse
Instance Attribute Details
#search ⇒ Object
sets definable attribute for search term
10 11 12 |
# File 'lib/tunespi.rb', line 10 def search @search end |
Instance Method Details
#get_and_parse(uri) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/tunespi.rb', line 12 def get_and_parse(uri) response = Net::HTTP.get(uri) # => String parsed = JSON.parse(response) a = [] # for each result, we want to make a hash of the specific results attributes, and put that # hash in an array parsed["results"].each do |x| a << Movie.new(name: x["trackName"], art: x["artworkUrl100"]) end return a end |
#search_movies ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/tunespi.rb', line 25 def search_movies q = URI.encode(self.search) puts = "ENCODED" puts q puts "************" uri = URI("https://itunes.apple.com/search?term=#{q}&entity=movie") get_and_parse(uri) end |