Sha256: 813e0491d27e91d0689e969a54f9600bd31d08ca61af645901dee88eb7aec739

Contents?: true

Size: 594 Bytes

Versions: 1

Compression:

Stored size: 594 Bytes

Contents

module Fandango
  module Movie

    class << self

      # Return array of movie attributes.
      def parse(description_node)
        description_node.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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fandango-1.0.0 lib/fandango/movie.rb