Class: ReDNS::Address

Inherits:
Fragment show all
Defined in:
lib/redns/address.rb

Instance Attribute Summary

Attributes inherited from Fragment

#attributes

Instance Method Summary collapse

Methods inherited from Fragment

attribute

Methods included from Support

#addr_to_arpa, #bind_all_addr, #default_nameservers, #default_resolver_address, #dns_port, #inet_aton, #inet_ntoa, #io_nonblock, #io_nonblock?, #io_set_nonblock, #is_ip?

Constructor Details

#initialize(contents = nil) ⇒ Address

Instance Methods =====================================================



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/redns/address.rb', line 10

def initialize(contents = nil)
  case (contents)
  when ReDNS::Buffer
    # Ensure that this String subclass is handled using the default
    # method, not intercepted and treated as an actual String
    super(contents)
  when String
    super(:address => contents)
  else
    super(contents)
  end
end

Instance Method Details

#deserialize(buffer) ⇒ Object



40
41
42
43
# File 'lib/redns/address.rb', line 40

def deserialize(buffer)
  self.address = inet_ntoa(buffer)
  self
end

#empty?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/redns/address.rb', line 23

def empty?
  self.address == '0.0.0.0'
end

#serialize(buffer = ReDNS::Buffer.new) ⇒ Object



35
36
37
38
# File 'lib/redns/address.rb', line 35

def serialize(buffer = ReDNS::Buffer.new)
  buffer.append(inet_aton(self.address))
  buffer
end

#to_aObject



31
32
33
# File 'lib/redns/address.rb', line 31

def to_a
	[ to_s ]
end

#to_sObject



27
28
29
# File 'lib/redns/address.rb', line 27

def to_s
  self.address
end