Method: DNS::Header::Type#initialize

Defined in:
lib/faildns/header/type.rb

#initialize(value) ⇒ Type

Returns a new instance of Type.



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/faildns/header/type.rb', line 37

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