Sha256: 151d49a25373d1048f885f0000f08a4c05883a312b6f07f1646322d2059e6a05
Contents?: true
Size: 1.04 KB
Versions: 5
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true require 'nokogiri' require_relative './event' require_relative './updated' module ForwardCalendar class ForwardCalendar def initialize(file) @file = file end ## # Immidiately returns the Updated element as soon as it gets parsed. # (Avoids the complete traverse of the file if the Updated element is set # at the beggining of the file) # def updated Nokogiri::XML::Reader(@file).each do |node| next unless node.name == 'updated' && node.node_type == Nokogiri::XML::Reader::TYPE_ELEMENT return Updated.parse(Nokogiri::XML(node.outer_xml), single: true) end end ## # Yields each Event from the Snapshot file being parsed. # def each_event Nokogiri::XML::Reader(@file).each do |node| next unless node.name == 'event' && node.node_type == Nokogiri::XML::Reader::TYPE_ELEMENT parsed_event = Nokogiri::XML.parse(node.outer_xml).remove_namespaces! yield Event.parse(parsed_event, single: true) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems