class IML::Base
Base
media file class
Public Instance Methods
imdb()
click to toggle source
# File lib/iml/base.rb, line 5 def imdb return nil unless imdb_doc fetch_director fetch_rating fetch_writer fetch_summary fetch_actors self end
Private Instance Methods
fetch_actors()
click to toggle source
# File lib/iml/base.rb, line 48 def fetch_actors self.actors ||= imdb_doc.css('span[itemprop=actors]').css('span[itemprop=name]').map { |e| e.child.to_s }.join(', ') end
fetch_director()
click to toggle source
# File lib/iml/base.rb, line 32 def fetch_director self.director ||= imdb_doc.css('span[itemprop=director]').css('span[itemprop=name]').map { |e| e.child.to_s }.join(', ') end
fetch_rating()
click to toggle source
# File lib/iml/base.rb, line 36 def fetch_rating self.rating ||= imdb_doc.css('span.rating').first.child.to_s end
fetch_summary()
click to toggle source
# File lib/iml/base.rb, line 44 def fetch_summary self.summary ||= imdb_doc.css('div.summary_text').text.strip end
fetch_writer()
click to toggle source
# File lib/iml/base.rb, line 40 def fetch_writer self.writer ||= imdb_doc.css('span[itemprop=creator]').css('span[itemprop=name]').map { |e| e.child.to_s }.join(', ') end
imdb_doc()
click to toggle source
# File lib/iml/base.rb, line 25 def imdb_doc link = imdb_link return nil unless imdb_link @html ||= open("https://www.imdb.com#{link}").read @imdb_doc ||= Nokogiri::HTML(@html) end
imdb_link()
click to toggle source
# File lib/iml/base.rb, line 17 def imdb_link search = IML::IMDB.new(title) result = search.result return nil if result.empty? self.year = result.first.year result.first.try(:href) end