Class: IMDB::Search
- Inherits:
-
Object
- Object
- IMDB::Search
- Defined in:
- lib/imdb/search.rb
Instance Method Summary collapse
Instance Method Details
#movie(keyword) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/imdb/search.rb', line 3 def movie(keyword) doc = Nokogiri::HTML(open("http://www.imdb.com/find?s=tt&q=#{CGI.escape(keyword)}")) @ret_val = [] doc.search('a[@href^="/title/tt"]').reject { |node| @ret_val.push(IMDB::Result.new(node["href"][/\d+/], node.content, "http://www.imdb.com#{node['href']}")) unless node.content.blank? } @ret_val end |
#to_hash ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/imdb/search.rb', line 12 def to_hash i = 0 tmp_hash = {} @ret_val.each {|r| tmp_hash[i] = r.to_hash i = i + 1 } tmp_hash end |
#to_json ⇒ Object
22 23 24 |
# File 'lib/imdb/search.rb', line 22 def to_json to_hash.to_json end |