class MultimediaParadise::ImdbRating

Constants

NAMESPACE
#

NAMESPACE

#
USE_THIS_REGEX
#

USE_THIS_REGEX

The Rating-specific String may look like this:

Rating: 7,6/10 · ‎160,162 votes
#

See: rubular.com/r/wO46isDDw1R3NM

#

Public Class Methods

[](i = '') click to toggle source
#

MultimediaParadise::ImdbRating[]

#
# File lib/multimedia_paradise/video/imdb_rating/imdb_rating.rb, line 132
def self.[](i = '')
  new(i)
end
new( commandline_arguments = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/multimedia_paradise/video/imdb_rating/imdb_rating.rb, line 59
def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Public Instance Methods

obtain_google_search_result() click to toggle source
#

obtain_google_search_result

This method will obtain the google page.

#
# File lib/multimedia_paradise/video/imdb_rating/imdb_rating.rb, line 99
def obtain_google_search_result
  # modified_input = '%22'+original_input.map {|entry|
  #   entry.capitalize
  # }.join('+')+'%22'
  simple_input = commandline_arguments?.map {|entry| entry.capitalize }
  _ = return_google_string_for_this_URL(simple_input)
  #'https://www.google.com/search?client=firefox-b-e&q='+
  #    'https://www.google.com/search?as_q='+
  #    modified_input+
  #    '&as_epq=&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all&as_sitesearch=&as_occt=any&safe=active&as_filetype=&tbs='
  #_ = _.dup
  e
  e sfancy(_)
  e
  dataset = URI.open(_).read # Encoding is now ISO-8859-1.
  dataset = dataset.encode('UTF-8')
  # dataset = dataset.force_encoding('UTF-8')
  scanned_results = ::Cyberweb.remove_html(dataset).scan(USE_THIS_REGEX)
  e 'The rating for `'+steelblue(commandline_arguments?.join(' ').to_s)+
    '` is: '+
    steelblue(scanned_results.flatten.first.to_f.to_s)
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method MultimediaParadise::Base#reset
# File lib/multimedia_paradise/video/imdb_rating/imdb_rating.rb, line 73
def reset
  super()
  # ======================================================================= #
  # === @namespace
  # ======================================================================= #
  @namespace = NAMESPACE
end
return_google_string_for_this_URL(this_URL) click to toggle source
#

return_google_string_for_this_URL

The task for this method is to return the String that can be used for a google-search.

#
# File lib/multimedia_paradise/video/imdb_rating/imdb_rating.rb, line 87
def return_google_string_for_this_URL(this_URL)
  this_URL = this_URL.join(' ') if this_URL.is_a? Array
  this_URL = this_URL.to_s.tr(' ','+')
  result = 'https://www.google.com/search?q='+this_URL.to_s+'&pws=0&gl=us&source=hp&ei=rBemYaygJd6HjLsPgqC4uAg&iflsig=ALs-wAMAAAAAYaYlvDplQlqKL-PSwzmrsOGF0IaDWwHi&ved=0ahUKEwispvb1icD0AhXeA2MBHQIQDocQ4dUDCAk&uact=5&oq=imdb+naked+gun&gs_lcp=Cgdnd3Mtd2l6EAMyBQgAEIAEOgsILhCABBDHARDRAzoLCC4QgAQQxwEQowI6BQguEIAEOgsILhCABBDHARCvAVCUBliFHmD5H2gBcAB4AYABsAKIAYgSkgEIMTYuMS4yLjGYAQCgAQGwAQA&sclient=gws-wiz'
  return result.dup
end
run() click to toggle source
#

run (run tag)

#
# File lib/multimedia_paradise/video/imdb_rating/imdb_rating.rb, line 125
def run
  obtain_google_search_result
end