Class: Resolv::DNS::Label::Str

Inherits:
Object
  • Object
show all
Defined in:
lib/resolv.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string) ⇒ Str

Returns a new instance of Str.



1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
# File 'lib/resolv.rb', line 1255

def initialize(string)
  # A label is limited to 63 octets. [RFC 1035 2.3.4] Checking it here
  # makes it an invariant of the object: every label, however it was
  # built, fits in its length octet and cannot wrap it. Callers turn
  # this into the error their own contract promises.
  if string.bytesize > 63
    raise ArgumentError, "DNS label is too long (#{string.bytesize} bytes, max 63): #{string.inspect}"
  end
  @string = string
  # case insensivity of DNS labels doesn't apply non-ASCII characters. [RFC 4343]
  # This assumes @string is given in ASCII compatible encoding.
  @downcase = string.b.downcase
end

Instance Attribute Details

#downcaseObject (readonly)

Returns the value of attribute downcase.



1268
1269
1270
# File 'lib/resolv.rb', line 1268

def downcase
  @downcase
end

#stringObject (readonly)

Returns the value of attribute string.



1268
1269
1270
# File 'lib/resolv.rb', line 1268

def string
  @string
end

Instance Method Details

#==(other) ⇒ Object



1278
1279
1280
# File 'lib/resolv.rb', line 1278

def ==(other)
  return self.class == other.class && @downcase == other.downcase
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


1282
1283
1284
# File 'lib/resolv.rb', line 1282

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

#hashObject



1286
1287
1288
# File 'lib/resolv.rb', line 1286

def hash
  return @downcase.hash
end

#inspectObject



1274
1275
1276
# File 'lib/resolv.rb', line 1274

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

#to_sObject



1270
1271
1272
# File 'lib/resolv.rb', line 1270

def to_s
  return @string
end