Class: Dnsruby::Name::Label

Inherits:
Object
  • Object
show all
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.



343
344
345
346
347
348
349
# File 'lib/Dnsruby/name.rb', line 343

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
end

Instance Attribute Details

#downcaseObject (readonly)

Returns the value of attribute downcase.



350
351
352
# File 'lib/Dnsruby/name.rb', line 350

def downcase
  @downcase
end

#stringObject (readonly)

Returns the value of attribute string.



350
351
352
# File 'lib/Dnsruby/name.rb', line 350

def string
  @string
end

Class Method Details

.set_max_length(l) ⇒ Object



339
340
341
# File 'lib/Dnsruby/name.rb', line 339

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

.split(arg) ⇒ Object

Split a Name into its component Labels



332
333
334
335
336
337
# File 'lib/Dnsruby/name.rb', line 332

def self.split(arg)
  labels = []
  #        arg.scan(/[^\.]+/) {labels << Str.new($&)}
  arg.scan(/[^\.]+/) {labels << new($&)}
  return labels
end

Instance Method Details

#==(other) ⇒ Object



364
365
366
# File 'lib/Dnsruby/name.rb', line 364

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

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


368
369
370
# File 'lib/Dnsruby/name.rb', line 368

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

#hashObject



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

def hash
  return @downcase.hash
end

#inspectObject



360
361
362
# File 'lib/Dnsruby/name.rb', line 360

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

#lengthObject



356
357
358
# File 'lib/Dnsruby/name.rb', line 356

def length
  return @string.length
end

#to_sObject



352
353
354
# File 'lib/Dnsruby/name.rb', line 352

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