Class: Dnsruby::Name::Label

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/dnsruby/name.rb

Overview

Dnsruby::Label class

(RFC1035, section 3.1)

Constant Summary collapse

MaxLabelLength =
63
@@max_length =
MaxLabelLength

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string) ⇒ Label

Returns a new instance of Label.



396
397
398
399
400
401
402
403
# File 'lib/dnsruby/name.rb', line 396

def initialize(string)
  if (string.length > @@max_length)
    raise ResolvError.new("Label too long (#{string.length}, max length=#{MaxLabelLength}). Label = #{string}")
  end
  @downcase = string.downcase
  @string = string
  @string_length = string.length
end

Instance Attribute Details

#downcaseObject (readonly)

Returns the value of attribute downcase.



404
405
406
# File 'lib/dnsruby/name.rb', line 404

def downcase
  @downcase
end

#stringObject (readonly)

Returns the value of attribute string.



404
405
406
# File 'lib/dnsruby/name.rb', line 404

def string
  @string
end

Class Method Details

.set_max_length(l) ⇒ Object



392
393
394
# File 'lib/dnsruby/name.rb', line 392

def self.set_max_length(l)
  @@max_length=l
end

.split(arg) ⇒ Object

Split a Name into its component Labels



388
389
390
# File 'lib/dnsruby/name.rb', line 388

def self.split(arg)
  return Name.split(arg)
end

Instance Method Details

#<=>(other) ⇒ Object



418
419
420
# File 'lib/dnsruby/name.rb', line 418

def <=>(other)
  return (@downcase <=> other.downcase)
end

#==(other) ⇒ Object



423
424
425
# File 'lib/dnsruby/name.rb', line 423

def ==(other)
  return @downcase == other.downcase
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


427
428
429
# File 'lib/dnsruby/name.rb', line 427

def eql?(other)
  return self == other
end

#hashObject



431
432
433
# File 'lib/dnsruby/name.rb', line 431

def hash
  return @downcase.hash
end

#inspectObject



414
415
416
# File 'lib/dnsruby/name.rb', line 414

def inspect
  return "#<#{self.class} #{self.to_s}>"
end

#lengthObject



410
411
412
# File 'lib/dnsruby/name.rb', line 410

def length
  return @string_length
end

#to_sObject



406
407
408
# File 'lib/dnsruby/name.rb', line 406

def to_s
  return @string.to_s # + "."
end