Class: Omelete::MovieAgent
- Inherits:
-
Object
- Object
- Omelete::MovieAgent
- Defined in:
- lib/omelete/movie_agent.rb
Instance Method Summary collapse
-
#initialize(omelete_id) ⇒ MovieAgent
constructor
A new instance of MovieAgent.
- #movies ⇒ Object
Constructor Details
#initialize(omelete_id) ⇒ MovieAgent
Returns a new instance of MovieAgent.
11 12 13 14 |
# File 'lib/omelete/movie_agent.rb', line 11 def initialize(omelete_id) @client = Client.new @page_doc = @client.page_doc("cinema/#{omelete_id}") end |
Instance Method Details
#movies ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/omelete/movie_agent.rb', line 16 def movies if @page_doc movies=[] omelete_id, name, runtime, genre, , image = nil, nil, nil, nil, nil, nil @page_doc.css("div[class='programacao_filme']").each do |m| omelete_id = m.css("div[class='programacao_filme_desc'] h2").css("a")[0] omelete_id = omelete_id ? omelete_id["href"][/\d+/] : nil name = m.css("div[class='programacao_filme_desc'] h2 a").text movie = MovieInfo.new(omelete_id, name) image = m.css("div[class='programacao_filme_poster']").css("a")[0] genre = m.css("div[class='programacao_filme_desc'] h4").text.split(" - ")[0] movie.runtime = m.css("div[class='programacao_filme_desc'] h4").text.split(" - ")[1] = m.css("div[class='programacao_filme_desc'] h4").text.split(" - ")[2] movie.image = image ? image["href"] : nil movie. = ? [/\d+/] : nil movies << movie end movies else nil end end |