Class: Omelete::MovieDetailsAgent
- Inherits:
-
Object
- Object
- Omelete::MovieDetailsAgent
- Defined in:
- lib/omelete/movie_details_agent.rb
Instance Method Summary collapse
-
#initialize(movie_id) ⇒ MovieDetailsAgent
constructor
A new instance of MovieDetailsAgent.
- #movie ⇒ Object
Constructor Details
#initialize(movie_id) ⇒ MovieDetailsAgent
Returns a new instance of MovieDetailsAgent.
11 12 13 14 15 |
# File 'lib/omelete/movie_details_agent.rb', line 11 def initialize(movie_id) @client = Client.new @id = movie_id @page_doc = @client.page_doc("filme/#{movie_id}") end |
Instance Method Details
#movie ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/omelete/movie_details_agent.rb', line 17 def movie if @page_doc synopsis, cast, directed_by = nil, nil, nil movie = MovieInfo.new @id, nil movie.synopsis = @page_doc.css("div#tab_#{@id}_sinopse blockquote").text @page_doc.css("div#tab_#{@id}_ficha dl").children.each do |child| if child.node_name == "dd" && child.previous_element && child.previous_element.content == "Direção:" movie.directed_by = child.content.delete("\r\n") elsif child.node_name == "dd" && child.previous_element && child.previous_element.content == "Elenco:" movie.cast = child.content.delete("\r\n") end end movie else nil end end |