Class: Resolv::DNS::Label::Str
- Inherits:
-
Object
- Object
- Resolv::DNS::Label::Str
- Defined in:
- lib/resolv.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#downcase ⇒ Object
readonly
Returns the value of attribute downcase.
-
#string ⇒ Object
readonly
Returns the value of attribute string.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(string) ⇒ Str
constructor
A new instance of Str.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(string) ⇒ Str
Returns a new instance of Str.
1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 |
# File 'lib/resolv.rb', line 1352 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
#downcase ⇒ Object (readonly)
Returns the value of attribute downcase.
1365 1366 1367 |
# File 'lib/resolv.rb', line 1365 def downcase @downcase end |
#string ⇒ Object (readonly)
Returns the value of attribute string.
1365 1366 1367 |
# File 'lib/resolv.rb', line 1365 def string @string end |
Instance Method Details
#==(other) ⇒ Object
1375 1376 1377 |
# File 'lib/resolv.rb', line 1375 def ==(other) return self.class == other.class && @downcase == other.downcase end |
#eql?(other) ⇒ Boolean
1379 1380 1381 |
# File 'lib/resolv.rb', line 1379 def eql?(other) return self == other end |
#hash ⇒ Object
1383 1384 1385 |
# File 'lib/resolv.rb', line 1383 def hash return @downcase.hash end |
#inspect ⇒ Object
1371 1372 1373 |
# File 'lib/resolv.rb', line 1371 def inspect return "#<#{self.class} #{self}>" end |
#to_s ⇒ Object
1367 1368 1369 |
# File 'lib/resolv.rb', line 1367 def to_s return @string end |