Sha256: 36f96ac87c8e4da1ee93ef11a32f1234e3b1350d53928c8def072a93dbb05701
Contents?: true
Size: 834 Bytes
Versions: 1
Compression:
Stored size: 834 Bytes
Contents
require 'fandango/movie' require 'fandango/theater' module Fandango class Parser class << self def parse(source) parser = new(source) parser.parse end # Description content is wrapped in CDATA. # Parse it and return a parsed Nokogiri node. def parse_description(item_node) cdata = item_node.at_css('description') Nokogiri::HTML(cdata.content) end end def initialize(source) @source = source end def parse @doc = Nokogiri.XML(@source) @doc.css('item').map do |item_node| hash = {} description_node = self.class.parse_description(item_node) hash[:theater] = Theater.parse(item_node, description_node) hash[:movies] = Movie.parse(description_node) hash end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fandango-1.0.0 | lib/fandango/parser.rb |