Class: Puppet::Network::Resolver::CacheEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/network/resolver.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(records) ⇒ CacheEntry

Returns a new instance of CacheEntry.



9
10
11
12
13
# File 'lib/puppet/network/resolver.rb', line 9

def initialize(records)
  @records = records
  @resolution_time = Time.now
  @ttl = choose_lowest_ttl(records)
end

Instance Attribute Details

#recordsObject (readonly)

Returns the value of attribute records.



7
8
9
# File 'lib/puppet/network/resolver.rb', line 7

def records
  @records
end

#resolution_timeObject (readonly)

Returns the value of attribute resolution_time.



7
8
9
# File 'lib/puppet/network/resolver.rb', line 7

def resolution_time
  @resolution_time
end

#ttlObject (readonly)

Returns the value of attribute ttl.



7
8
9
# File 'lib/puppet/network/resolver.rb', line 7

def ttl
  @ttl
end

Instance Method Details

#choose_lowest_ttl(records) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/puppet/network/resolver.rb', line 15

def choose_lowest_ttl(records)
  ttl = records.first.ttl
  records.each do |rec|
    if rec.ttl < ttl
      ttl = rec.ttl
    end
  end
  ttl
end