Class: Symbol

Inherits:
Object show all
Defined in:
lib/core_ext/symbol.rb

Overview

Reopen the core Symbol class to represent #inspect_lit.

Instance Method Summary collapse

Instance Method Details

#inspect_litString

Formats this symbol to look like a symbol literal so that object type will be inherently obvious when used in logging methods, etc.

Examples:

:test.inspect_lit      # => ":\"test\"" (or ':"test"')
:"ta-da!".inspect_lit  # => ":\"ta-da!\"" (or ':"ta-da!"')

Returns:

  • (String)

    a symbol literal representation of this object



13
14
15
# File 'lib/core_ext/symbol.rb', line 13

def inspect_lit
  %(:"#{self}")
end