Sha256: 82ba5d47a46cd4c0fccd8674187f52d449767a56298a0f442a5307bd093769de

Contents?: true

Size: 581 Bytes

Versions: 12

Compression:

Stored size: 581 Bytes

Contents

module Fandango
  class Parser::Movie

    def initialize(entry)
      @entry = entry
    end

    # Return array of movie attributes.
    def parse
      @entry.summary_doc.css('li').map do |li|
        {
          title: parse_title(li),
          id:    parse_id(li),
        }
      end
    end

    private

    def parse_title(li)
      li.at_css('a').content
    end

    # E.g. '141081' in fandango.com/the+adventures+of+tintin+3d_141081/movietimes
    def parse_id(li)
      li.at_css('a')['href'].match(%r{fandango\.com/.*_(?<id>\d+)/movietimes})[:id]
    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
fandango-0.2.1 lib/fandango/parsers/movie.rb
fandango-0.2.0 lib/fandango/parsers/movie.rb
fandango-0.1.9 lib/fandango/parsers/movie.rb
fandango-0.1.8 lib/fandango/parsers/movie.rb
fandango-0.1.7 lib/fandango/parsers/movie.rb
fandango-0.1.6 lib/fandango/parsers/movie.rb
fandango-0.1.5 lib/fandango/parsers/movie.rb
fandango-0.1.4 lib/fandango/parsers/movie.rb
fandango-0.1.3 lib/fandango/parsers/movie.rb
fandango-0.1.2 lib/fandango/parsers/movie.rb
fandango-0.1.1 lib/fandango/parsers/movie.rb
fandango-0.1.0 lib/fandango/parsers/movie.rb