Method: HowLongToBeat::HowLongToBeat#search_from_id

Defined in:
lib/howlongtobeat/how_long_to_beat.rb

#search_from_id(game_id) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/howlongtobeat/how_long_to_beat.rb', line 18

def search_from_id(game_id)
  return nil if game_id.nil? || game_id == 0

  game_title = HTMLRequests.get_game_title(game_id)
  return nil unless game_title

  html_result = HTMLRequests.send_web_request(game_title)
  return nil unless html_result

  result_list = parse_web_result(game_title, html_result, game_id)
  return nil unless result_list && result_list.size == 1

  result_list.first
end