class ForwardCalendar::ForwardCalendar
Public Class Methods
new(file)
click to toggle source
# File lib/forward_calendar/forward_calendar.rb, line 9 def initialize(file) @file = file end
Public Instance Methods
each_event() { |parse(parsed_event, single: true)| ... }
click to toggle source
Yields each Event
from the Snapshot file being parsed.
# File lib/forward_calendar/forward_calendar.rb, line 28 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
updated()
click to toggle source
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)
# File lib/forward_calendar/forward_calendar.rb, line 18 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