class ThomasUtils::KeyComparer

Attributes

comparer[R]
key[R]

Public Class Methods

new(key, comparer) click to toggle source
# File lib/thomas_utils/key_comparer.rb, line 6
def initialize(key, comparer)
  @key = key
  @comparer = comparer
end

Public Instance Methods

==(rhs) click to toggle source
# File lib/thomas_utils/key_comparer.rb, line 28
def ==(rhs)
  rhs.is_a?(KeyComparer) && key == rhs.key && comparer == rhs.comparer
end
Also aliased as: eql?
eql?(rhs)
Alias for: ==
hash() click to toggle source
# File lib/thomas_utils/key_comparer.rb, line 33
def hash
  to_s.hash
end
new_key(updated_key) click to toggle source
# File lib/thomas_utils/key_comparer.rb, line 11
def new_key(updated_key)
  KeyComparer.new(updated_key, comparer)
end
quote(quote) click to toggle source
# File lib/thomas_utils/key_comparer.rb, line 15
def quote(quote)
  quoted_key = if key.respond_to?(:quote)
                 key.quote(quote)
               else
                 "#{quote}#{key}#{quote}"
               end
  "#{quoted_key} #{comparer}"
end
to_s() click to toggle source
# File lib/thomas_utils/key_comparer.rb, line 24
def to_s
  "#{pretty_key} #{comparer}"
end

Private Instance Methods

pretty_key() click to toggle source
# File lib/thomas_utils/key_comparer.rb, line 43
def pretty_key
  key.is_a?(Array) ? "(#{key * ','})" : key
end