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.



399
400
401
402
403
404
405
406
# File 'lib/dnsruby/name.rb', line 399

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

#downcase ⇒ Object (readonly)

Returns the value of attribute downcase.



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

def downcase
  @downcase
end

#string ⇒ Object (readonly)

Returns the value of attribute string.



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

def string
  @string
end

Class Method Details

.set_max_length(l) ⇒ Object



395
396
397
# File 'lib/dnsruby/name.rb', line 395

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

.split(arg) ⇒ Object

Split a Name into its component Labels



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

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

Instance Method Details

#<=>(other) ⇒ Object



421
422
423
# File 'lib/dnsruby/name.rb', line 421

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

#==(other) ⇒ Object



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

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

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#hash ⇒ Object



434
435
436
# File 'lib/dnsruby/name.rb', line 434

def hash
  return @downcase.hash
end

#inspect ⇒ Object



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

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

#length ⇒ Object



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

def length
  return @string_length
end

#to_s ⇒ Object



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

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