Sha256: d68162e6bc2b0c4540b1174eec19f44283df69117c0a23d3a549755690d1126a

Contents?: true

Size: 510 Bytes

Versions: 2

Compression:

Stored size: 510 Bytes

Contents

require "tinydns/record"

module TinyDNS
  class Parser
    def initialize(io)
      @io = io
    end

    def parse
      @io.split("\n").collect do |line|
        unless line.strip.start_with? "#"
          type = line[0]
          name, value, ttl, other = line[1..-1].split(":")
          record = {:type => type, :name => name, :value => value, :ttl => ttl}
          record.merge!(:other => other) if other
          Record.new(record)
        end
      end.reject {|item| item == nil}
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tinydns-data-0.0.2 lib/tinydns/parser.rb
tinydns-data-0.0.1 lib/tinydns/parser.rb