Class: DNSRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/DNSResolver.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDNSRecord

Returns a new instance of DNSRecord.



21
22
23
# File 'lib/DNSResolver.rb', line 21

def initialize
  @host = nil
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



18
19
20
# File 'lib/DNSResolver.rb', line 18

def host
  @host
end

#timeStampObject

Returns the value of attribute timeStamp.



19
20
21
# File 'lib/DNSResolver.rb', line 19

def timeStamp
  @timeStamp
end

Instance Method Details

#resolve(ip) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/DNSResolver.rb', line 25

def resolve(ip)
  begin
    a = Socket.gethostbyname(ip)
    @host = Socket.gethostbyaddr(a[3], a[2])[0]
  rescue
    @host = ip
  end
  @timeStamp =  Time.now()
end