Class: Net::DNS::PTRRecord

Inherits:
Record show all
Defined in:
lib/net/dns/ptr_record.rb

Constant Summary

Constants included from Validations

Validations::IP_REGEXP, Validations::MAC_REGEXP

Instance Attribute Summary

Attributes inherited from Record

#ip, #resolver, #type

Attributes inherited from Record

#hostname, #logger, #proxy

Instance Method Summary collapse

Methods inherited from Record

#dns_lookup

Methods inherited from Record

#==, #conflicting?, #inspect, #reload!

Methods included from Validations

normalize_ip, normalize_mac, #validate_ip, #validate_mac, #validate_network

Constructor Details

#initialize(opts = { }) ⇒ PTRRecord


4
5
6
7
# File 'lib/net/dns/ptr_record.rb', line 4

def initialize opts = { }
  super opts
  @type = "PTR"
end

Instance Method Details

#aObject


36
37
38
# File 'lib/net/dns/ptr_record.rb', line 36

def a
  dns_lookup(hostname)
end

#attrsObject


40
41
42
# File 'lib/net/dns/ptr_record.rb', line 40

def attrs
  { :fqdn => hostname, :value => to_arpa, :type => type }
end

#conflictsObject

Returns an array of record objects which are conflicting with our own


26
27
28
# File 'lib/net/dns/ptr_record.rb', line 26

def conflicts
  @conflicts ||= [dns_lookup(ip)].delete_if{|c| c == self}.compact
end

#createObject


18
19
20
21
22
23
# File 'lib/net/dns/ptr_record.rb', line 18

def create
  super
  proxy.set attrs
rescue RestClient::Conflict
  raise generate_conflict_error
end

#destroyObject


13
14
15
16
# File 'lib/net/dns/ptr_record.rb', line 13

def destroy
  super
  proxy.delete(to_arpa)
end

#to_sObject


9
10
11
# File 'lib/net/dns/ptr_record.rb', line 9

def to_s
  "#{ip}/#{hostname}"
end

#valid?Boolean

Verifies that a record already exists on the dns server


31
32
33
34
# File 'lib/net/dns/ptr_record.rb', line 31

def valid?
  logger.debug "Fetching DNS reservation for #{to_s}"
  self == dns_lookup(ip)
end