Sha256: f49935bd39eb4d6f886b9b7c8f5ba02c81603b0b5314c8af580800f7f672f18f
Contents?: true
Size: 837 Bytes
Versions: 12
Compression:
Stored size: 837 Bytes
Contents
module Fandango class Parser::Theater def initialize(entry) @entry = entry end # Compose hash with each attribute as key and result of #parse_<attribute> as value. def parse atts = [:name, :id, :address, :postal_code] atts.each_with_object({}) do |attr, hash| hash[attr] = send :"parse_#{attr}" end end private def parse_name @entry[:title] end # E.g. 'aaicu' in http://www.fandango.com/northpark7_aaicu/theaterpage def parse_id @entry[:url].match(%r{fandango\.com/.*_(?<id>.*)/theaterpage})[:id] end # Cache address in variable for postal_code. def parse_address @address = @entry.summary_doc.at_css('p').content end def parse_postal_code @address.match(/(?<postal_code>\d+)$/)[:postal_code] end end end
Version data entries
12 entries across 12 versions & 1 rubygems