Class: Dnsync::Record

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/dnsync/record.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, ttl, answers) ⇒ Record

Returns a new instance of Record.



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/dnsync/record.rb', line 12

def initialize(name, type, ttl, answers)
  unless ttl.present?
    raise ArgumentError, 'ttl must be provided'
  end

  @identifier = RecordIdentifier.new(name, type)
  @ttl        = ttl
  @answers    = answers.sort

  freeze
end

Instance Attribute Details

#answersObject (readonly)

Returns the value of attribute answers.



10
11
12
# File 'lib/dnsync/record.rb', line 10

def answers
  @answers
end

#identifierObject (readonly)

Returns the value of attribute identifier.



10
11
12
# File 'lib/dnsync/record.rb', line 10

def identifier
  @identifier
end

#ttlObject (readonly)

Returns the value of attribute ttl.



10
11
12
# File 'lib/dnsync/record.rb', line 10

def ttl
  @ttl
end

Instance Method Details

#<=>(other) ⇒ Object



32
33
34
# File 'lib/dnsync/record.rb', line 32

def <=>(other)
  [ identifier, ttl, answers ] <=> [ other.identifier, other.ttl, other.answers ]
end

#hashObject



36
37
38
# File 'lib/dnsync/record.rb', line 36

def hash
  [ identifier, ttl, answers ].hash
end

#nameObject



24
25
26
# File 'lib/dnsync/record.rb', line 24

def name
  @identifier.name
end

#typeObject



28
29
30
# File 'lib/dnsync/record.rb', line 28

def type
  @identifier.type
end