class String

Reopen the core String class to represent {#inspect_lit}.

Public Instance Methods

inspect_lit() click to toggle source

Formats self to look like a String literal so that object type will be inherently obvious when inspected.

@return [String] a String-literal representation of this object

@example

"test".inspect_lit  # => "\"test\"" (i.e. '"test"')
"1".inspect_lit     # => "\"1\""    (i.e. '"1"')
"12.3".inspect_lit  # => "\"12.3\"" (i.e. '"12.3"')
# File lib/core_ext/string.rb, line 14
def inspect_lit
  %("#{self}")
end