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.



380
381
382
383
384
385
386
387
# File 'lib/dnsruby/name.rb', line 380

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.



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

def downcase
  @downcase
end

#stringObject (readonly)

Returns the value of attribute string.



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

def string
  @string
end

Class Method Details

.set_max_length(l) ⇒ Object



376
377
378
# File 'lib/dnsruby/name.rb', line 376

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

.split(arg) ⇒ Object

Split a Name into its component Labels



372
373
374
# File 'lib/dnsruby/name.rb', line 372

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

Instance Method Details

#<=>(other) ⇒ Object



402
403
404
# File 'lib/dnsruby/name.rb', line 402

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

#==(other) ⇒ Object



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

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

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#hashObject



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

def hash
  return @downcase.hash
end

#inspectObject



398
399
400
# File 'lib/dnsruby/name.rb', line 398

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

#lengthObject



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

def length
  return @string_length
end

#to_sObject



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

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