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

Inherits:
Object
  • Object
show all
Defined in:
lib/net/dns/resolv.rb,
lib/net/dns/resolvx.rb

Overview

A String wrapper that compares (and hashes) case insensitively, used to represent DNS labels.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string) ⇒ Str

:nodoc:



994
995
996
997
# File 'lib/net/dns/resolv.rb', line 994

def initialize(string) # :nodoc:
  @string = string
  @downcase = string.downcase
end

Instance Attribute Details

#downcaseObject (readonly)

Returns the value of attribute downcase.



998
999
1000
# File 'lib/net/dns/resolv.rb', line 998

def downcase
  @downcase
end

#stringObject (readonly)

Returns the value of attribute string.



998
999
1000
# File 'lib/net/dns/resolv.rb', line 998

def string
  @string
end

Instance Method Details

#<=>(s) ⇒ Object

Case-insensitive comparison.



71
72
73
# File 'lib/net/dns/resolvx.rb', line 71

def <=>(s)
  @downcase <=> s.downcase
end

#==(other) ⇒ Object



1008
1009
1010
# File 'lib/net/dns/resolv.rb', line 1008

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

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


1012
1013
1014
# File 'lib/net/dns/resolv.rb', line 1012

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

#hashObject



1016
1017
1018
# File 'lib/net/dns/resolv.rb', line 1016

def hash
  return @downcase.hash
end

#inspectObject



1004
1005
1006
# File 'lib/net/dns/resolv.rb', line 1004

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

#to_sObject



1000
1001
1002
# File 'lib/net/dns/resolv.rb', line 1000

def to_s
  return @string
end

#to_strObject

Str is-a String, allow it to be compared to one.



67
68
69
# File 'lib/net/dns/resolvx.rb', line 67

def to_str
  return @string
end