class Lita::Handlers::Howlongtobeat::HowlongtobeatSearch

Constants

SEARCH_URL
SITE_URL

Public Class Methods

new(term, client = Faraday) click to toggle source
# File lib/lita/handlers/howlongtobeat.rb, line 15
def initialize(term, client = Faraday)
  @term = term
  @client = client
end

Public Instance Methods

doc() click to toggle source
# File lib/lita/handlers/howlongtobeat.rb, line 44
def doc
  @data ||= begin
    search = @client.post(SEARCH_URL, queryString: @term, t: 'games', sorthead: 'popular', sortd: 'Normal Order', detail: '0')
    Nokogiri::HTML(search.body)
  end
end
print_result(response) click to toggle source
story() click to toggle source
# File lib/lita/handlers/howlongtobeat.rb, line 27
def story
  text = doc.css(".search_list_tidbit.center")[0].text
  text == '--' ? nil : text
end
title() click to toggle source
# File lib/lita/handlers/howlongtobeat.rb, line 32
def title
  doc.css('a')[0]
end
title_content() click to toggle source
# File lib/lita/handlers/howlongtobeat.rb, line 40
def title_content
  title ? title.attr('title') : nil
end
title_href() click to toggle source
# File lib/lita/handlers/howlongtobeat.rb, line 36
def title_href
  title ? title.attr('href') : nil
end