Sha256: ac4c97d281112ae25d0f709c7d1cc926f5e3f190918df790e8026e501ec1184a

Contents?: true

Size: 524 Bytes

Versions: 19

Compression:

Stored size: 524 Bytes

Contents

module Lipseys
  class Parser

    attr_reader :file

    def initialize(file)
      @file = file
    end

    def self.parse(file, node_name, &block)
      new(file).parse(node_name, &block)
    end

    def parse(node_name, &block)
      File.open(@file) do |file|
        Nokogiri::XML::Reader.from_io(file).each do |node|
          if node.name == node_name and node.node_type == Nokogiri::XML::Reader::TYPE_ELEMENT
            yield(Nokogiri::XML(node.outer_xml))
          end
        end
      end
    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
lipseys-5.0.1 lib/lipseys/parser.rb
lipseys-5.0.0 lib/lipseys/parser.rb
lipseys-4.0.0 lib/lipseys/parser.rb
lipseys-3.0.1 lib/lipseys/parser.rb
lipseys-3.0.0 lib/lipseys/parser.rb
lipseys-2.1.0 lib/lipseys/parser.rb
lipseys-2.0.9 lib/lipseys/parser.rb
lipseys-2.0.8 lib/lipseys/parser.rb
lipseys-2.0.7 lib/lipseys/parser.rb
lipseys-2.0.6 lib/lipseys/parser.rb
lipseys-2.0.5 lib/lipseys/parser.rb
lipseys-2.0.4 lib/lipseys/parser.rb
lipseys-2.0.3 lib/lipseys/parser.rb
lipseys-2.0.2 lib/lipseys/parser.rb
lipseys-2.0.1 lib/lipseys/parser.rb
lipseys-2.0 lib/lipseys/parser.rb
lipseys-1.0.1 lib/lipseys/parser.rb
lipseys-1.0.1.pre lib/lipseys/parser.rb
lipseys-1.0.0.pre lib/lipseys/parser.rb