Skip to content

Commit

Permalink
Added the Object#encoded_hash method to find the encoded hash used in…
Browse files Browse the repository at this point in the history
… inspect.
  • Loading branch information
mtodd committed Sep 2, 2008
1 parent f8e1fec commit 61fcabb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/extlib/object.rb
Expand Up @@ -141,4 +141,17 @@ def in?(arrayish,*more)
arrayish = more.unshift(arrayish) unless more.empty?
arrayish.include?(self)
end

# @note
# For instances of objects that don't override the #inspect method, there
# is an encoded hash to uniquely identify the object. This method
# reproduces this to be used in #inspect in order to keep the same look
# as well as provide this information.
# This is inessential, but may be useful.
#
# @return <String>
# Returns the 16-byte encoded hash for the object
def encoded_hash
(self.hash * 2).to_s(16)
end
end

0 comments on commit 61fcabb

Please sign in to comment.