Class: Dnsruby::RR::NXT::TypeBitmap

Inherits:
Object
  • Object
show all
Defined in:
lib/dnsruby/resource/NXT.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bitmap_number) ⇒ TypeBitmap

Returns a new instance of TypeBitmap.



278
279
280
281
# File 'lib/dnsruby/resource/NXT.rb', line 278

def initialize(bitmap_number)
  NxtTypes.assert_legal_bitmap_value(bitmap_number)
  @bitmap = Bitmap.from_number(bitmap_number)
end

Instance Attribute Details

#bitmapObject

Returns the value of attribute bitmap.



256
257
258
# File 'lib/dnsruby/resource/NXT.rb', line 256

def bitmap
  @bitmap
end

Class Method Details

.from_binary_string(binary_string) ⇒ Object

Create an instance from a binary string, e.g. from a NXT record RDATA:



271
272
273
# File 'lib/dnsruby/resource/NXT.rb', line 271

def self.from_binary_string(binary_string)
  new(BitMapping.binary_string_to_number(binary_string))
end

.from_names_string(names_string) ⇒ Object

Create an instance from a string containing type names separated by spaces e.g. “A TXT NXT”



260
261
262
263
# File 'lib/dnsruby/resource/NXT.rb', line 260

def self.from_names_string(names_string)
  type_codes = BitMapping.names_string_to_codes(names_string)
  from_type_codes(type_codes)
end

.from_type_codes(type_codes) ⇒ Object

Create an instance from type numeric codes (e.g. 30 for NXT).



266
267
268
# File 'lib/dnsruby/resource/NXT.rb', line 266

def self.from_type_codes(type_codes)
  new(BitMapping.set_bit_position_array_to_number(type_codes))
end

Instance Method Details

#to_binary_stringObject

Returns a binary string representing this data, in as few bytes as possible (i.e. no leading zero bytes).



285
286
287
# File 'lib/dnsruby/resource/NXT.rb', line 285

def to_binary_string
  bitmap.to_binary_string
end

#to_sObject

Output types in dig format, e.g. “A AAAA NXT”



295
296
297
298
# File 'lib/dnsruby/resource/NXT.rb', line 295

def to_s
  type_codes = bitmap.to_set_bit_position_array
  NxtTypes.codes_to_string(type_codes)
end

#to_type_arrayObject

Returns the instance’s data as an array of type codes.



290
291
292
# File 'lib/dnsruby/resource/NXT.rb', line 290

def to_type_array
  bitmap.to_set_bit_position_array
end