022df7f893582e7e8efffce816ae27f6d1015766Eugen Kuksamodule Hets
022df7f893582e7e8efffce816ae27f6d1015766Eugen Kuksa module DG
022df7f893582e7e8efffce816ae27f6d1015766Eugen Kuksa class Parser
022df7f893582e7e8efffce816ae27f6d1015766Eugen Kuksa attr_accessor :resource, :callback
022df7f893582e7e8efffce816ae27f6d1015766Eugen Kuksa
022df7f893582e7e8efffce816ae27f6d1015766Eugen Kuksa def initialize(resource)
022df7f893582e7e8efffce816ae27f6d1015766Eugen Kuksa self.resource = resource
022df7f893582e7e8efffce816ae27f6d1015766Eugen Kuksa end
022df7f893582e7e8efffce816ae27f6d1015766Eugen Kuksa
022df7f893582e7e8efffce816ae27f6d1015766Eugen Kuksa def parse(callback: nil)
022df7f893582e7e8efffce816ae27f6d1015766Eugen Kuksa input = resource.respond_to?(:close) ? resource : File.open(resource)
022df7f893582e7e8efffce816ae27f6d1015766Eugen Kuksa parser(callback).parse(input)
022df7f893582e7e8efffce816ae27f6d1015766Eugen Kuksa input.close
022df7f893582e7e8efffce816ae27f6d1015766Eugen Kuksa end
022df7f893582e7e8efffce816ae27f6d1015766Eugen Kuksa
022df7f893582e7e8efffce816ae27f6d1015766Eugen Kuksa private
022df7f893582e7e8efffce816ae27f6d1015766Eugen Kuksa def parser(callback)
022df7f893582e7e8efffce816ae27f6d1015766Eugen Kuksa listener = NokogiriListener.new(callback)
022df7f893582e7e8efffce816ae27f6d1015766Eugen Kuksa Nokogiri::XML::SAX::Parser.new(listener)
022df7f893582e7e8efffce816ae27f6d1015766Eugen Kuksa end
022df7f893582e7e8efffce816ae27f6d1015766Eugen Kuksa end
022df7f893582e7e8efffce816ae27f6d1015766Eugen Kuksa end
022df7f893582e7e8efffce816ae27f6d1015766Eugen Kuksaend