Class: DNS::Header::Opcode
- Inherits:
-
Object
- Object
- DNS::Header::Opcode
- Defined in:
- lib/faildns/header/opcode.rb
Overview
– OPCODE A four bit field that specifies kind of query in this
message. This value is set by the originator of a query
and copied into the response. The values are:
0 a standard query (QUERY)
1 an inverse query (IQUERY)
2 a server status request (STATUS)
3-15 reserved for future use
++
Constant Summary collapse
- Values =
{ 0 => :QUERY, 1 => :IQUERY, 2 => :STATUS, 3 => :RESERVED3, 4 => :NOTIFY, 5 => :UPDATE, 6 => :RESERVED6, 7 => :RESERVED7, 8 => :RESERVED8, 9 => :RESERVED9, 10 => :RESERVED10, 11 => :RESERVED11, 12 => :RESERVED12, 13 => :RESERVED13, 14 => :RESERVED14, 15 => :RESERVED15 }
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(what) ⇒ Object
-
#initialize(value) ⇒ Opcode
constructor
A new instance of Opcode.
- #to_s ⇒ Object
- #to_sym ⇒ Object
Constructor Details
#initialize(value) ⇒ Opcode
Returns a new instance of Opcode.
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/faildns/header/opcode.rb', line 60 def initialize (value) if value.is_a? Symbol @value = Values.find {|key, val| val == value}.first rescue nil elsif value.is_a? Integer @value = value else @value = value.value rescue nil end if !self.to_sym raise ArgumentError.new('The passed value is not a suitable type.') end end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
58 59 60 |
# File 'lib/faildns/header/opcode.rb', line 58 def value @value end |
Instance Method Details
#==(what) ⇒ Object
74 75 76 77 78 79 80 81 82 |
# File 'lib/faildns/header/opcode.rb', line 74 def == (what) if what.is_a? Symbol self.to_sym == what elsif value.is_a? Integer @value == what else @value == what.value rescue false end end |
#to_s ⇒ Object
88 89 90 |
# File 'lib/faildns/header/opcode.rb', line 88 def to_s Values[@value].to_s end |
#to_sym ⇒ Object
84 85 86 |
# File 'lib/faildns/header/opcode.rb', line 84 def to_sym Values[@value] end |