Class: Dnsruby::Name::Label
- Inherits:
-
Object
- Object
- Dnsruby::Name::Label
- 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
-
#downcase ⇒ Object
readonly
Returns the value of attribute downcase.
-
#string ⇒ Object
readonly
Returns the value of attribute string.
Class Method Summary collapse
- .set_max_length(l) ⇒ Object
-
.split(arg) ⇒ Object
Split a Name into its component Labels.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(string) ⇒ Label
constructor
A new instance of Label.
- #inspect ⇒ Object
- #length ⇒ Object
- #to_s ⇒ Object
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
#downcase ⇒ Object (readonly)
Returns the value of attribute downcase.
350 351 352 |
# File 'lib/Dnsruby/name.rb', line 350 def downcase @downcase end |
#string ⇒ Object (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
368 369 370 |
# File 'lib/Dnsruby/name.rb', line 368 def eql?(other) return self == other end |
#hash ⇒ Object
372 373 374 |
# File 'lib/Dnsruby/name.rb', line 372 def hash return @downcase.hash end |
#inspect ⇒ Object
360 361 362 |
# File 'lib/Dnsruby/name.rb', line 360 def inspect return "#<#{self.class} #{self.to_s}>" end |
#length ⇒ Object
356 357 358 |
# File 'lib/Dnsruby/name.rb', line 356 def length return @string.length end |
#to_s ⇒ Object
352 353 354 |
# File 'lib/Dnsruby/name.rb', line 352 def to_s return @string.to_s # + "." end |