Class: IMDB
- Inherits:
-
Object
- Object
- IMDB
- Defined in:
- lib/imdb.rb
Defined Under Namespace
Modules: StringStripper
Constant Summary
- @@URL =
'http://www.imdb.com/search/title/'
Instance Method Summary (collapse)
- - (Object) get_image(url, path, x = 160)
- - (Object) get_list(options = {})
- - (Object) next
- - (Object) reset
Instance Method Details
- (Object) get_image(url, path, x = 160)
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/imdb.rb', line 39 def get_image(url, path, x = 160) # http://ia.media-imdb.com/images/*.jpg if url.match(/^http:\/\/ia\.media-imdb\.com\/images\/.*\.jpg/) base = url.split('._V1._')[0] style = "._V1._SX#{x}_.jpg" final = base + style begin File.open(path, 'w') do |f| open(final) { |stream| f << stream.read } end return true rescue File.delete(path) puts "Error to save image at '#{final}'" return false end end return false end |
- (Object) get_list(options = {})
19 20 21 22 23 |
# File 'lib/imdb.rb', line 19 def get_list( = {}) @start = [:start] || 1 set_request() return perform_list_search { |step, max, text| yield(step, max, text) if block_given? } end |
- (Object) next
26 27 28 29 30 |
# File 'lib/imdb.rb', line 26 def next return {} if @params.nil? @start = @start + 50 return perform_list_search { |step, max, text| yield(step, max, text) if block_given? } end |
- (Object) reset
33 34 35 36 |
# File 'lib/imdb.rb', line 33 def reset @params = nil @start = 1 end |