Class: TalkTalkTV::Search

Inherits:
Object
  • Object
show all
Defined in:
lib/talktalk_tv/search.rb

Instance Method Summary collapse

Instance Method Details

#search(query) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/talktalk_tv/search.rb', line 7

def search(query)
  r = response(query)
  films = film_fragments(r.body).map { |f|
    Film.new(
      title: film_title(f),
      url: film_url(f),
      image_url: film_image_url(f),
      certificate: film_certificate(f),
      running_time_in_minutes: film_running_time_in_minutes(f)
    )
  }

  if films.empty? & !no_results_page?(r.body)
    raise TalkTalkTV::SearchResultsPageNotRecognised
  else
    films
  end
end