# Resolv::DNS::Message::MessageEncoder (Class)

In: | resolv.rb
Parent: | Object

## Methods

new put_bytes put_label put_labels put_length16 put_name put_pack put_string to_s

## Public Class methods

new() {|self| ...}

[Source]

    # File resolv.rb, line 1058
            def initialize
              @data = ''
              @names = {}
              yield self
            end

## Public Instance methods

to_s()

[Source]

    # File resolv.rb, line 1064
            def to_s
              return @data
            end

put_bytes(d)

[Source]

    # File resolv.rb, line 1068
            def put_bytes(d)
              @data << d
            end

put_pack(template, *d)

[Source]

    # File resolv.rb, line 1072
            def put_pack(template, *d)
              @data << d.pack(template)
            end

put_length16() {|| ...}

[Source]

    # File resolv.rb, line 1076
            def put_length16
              length_index = @data.length
              @data << "\0\0"
              data_start = @data.length
              yield
              data_end = @data.length
              @data[length_index, 2] = [data_end - data_start].pack("n")
            end

put_string(d)

[Source]

    # File resolv.rb, line 1085
            def put_string(d)
              self.put_pack("C", d.length)
              @data << d
            end

put_name(d)

[Source]

    # File resolv.rb, line 1090
            def put_name(d)
              put_labels(d.to_a)
            end

put_labels(d)

[Source]

    # File resolv.rb, line 1094
            def put_labels(d)
              d.each_index {|i|
                domain = d[i..-1]
                if idx = @names[domain]
                  self.put_pack("n", 0xc000 | idx)
                  return
                else
                  @names[domain] = @data.length
                  self.put_label(d[i])
                end
              }
              @data << "\0"
            end

put_label(d)

[Source]

    # File resolv.rb, line 1108
            def put_label(d)
              self.put_string(d.string)
            end

[Validate]