Class: Dnsync::Answer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content, priority = nil) ⇒ Answer

Returns a new instance of Answer.



7
8
9
10
11
12
13
14
15
16
# File 'lib/dnsync/answer.rb', line 7

def initialize(content, priority = nil)
  unless content.present?
    raise ArgumentError, 'content must be provided'
  end

  @content  = content
  @priority = priority

  freeze
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



5
6
7
# File 'lib/dnsync/answer.rb', line 5

def content
  @content
end

#priorityObject (readonly)

Returns the value of attribute priority.



5
6
7
# File 'lib/dnsync/answer.rb', line 5

def priority
  @priority
end

Instance Method Details

#<=>(other) ⇒ Object



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

def <=>(other)
  [ content, priority ] <=> [ other.content, other.priority ]
end

#hashObject



22
23
24
# File 'lib/dnsync/answer.rb', line 22

def hash
  [ content, priority ].hash
end