Sha256: 5a2e71876abd67fb525d8a6b0eb8c8475067e9c4120a08d225f76c2d0f598ac7

Contents?: true

Size: 666 Bytes

Versions: 1

Compression:

Stored size: 666 Bytes

Contents

module TinyDNS
  class Record < Hash
    def initialize(params = {})
      params.each do |k,v|
        self[k] = v
      end
    end

    def type
      case self[:type]
        when "C"
          :cname
        when "="
          :a
        when "@"
          :mx
        when "."
          :soa
        when "'"
          :text
        else
          self[:type]
      end
    end

    def name
      self[:name]
    end

    def value
      self[:value]
    end

    def ttl
      self[:ttl]
    end

    def to_str
      str = "#{self[:type]}#{name}:#{value}:#{ttl}"
      if self[:other]
        str << ":#{self[:other]}"
      end
      str
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tinydns-data-0.0.2 lib/tinydns/record.rb