Sha256: 36b61aa825334eb4048be4a488683900b2c72232f9be2099bbbff5c33592df58

Contents?: true

Size: 523 Bytes

Versions: 9

Compression:

Stored size: 523 Bytes

Contents

# frozen_string_literal: true

# Reopen the core String class to represent {#inspect_lit}.
class String
  # 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"')
  def inspect_lit
    %("#{self}")
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
object_identifier-0.8.0 lib/core_ext/string.rb
object_identifier-0.7.0 lib/core_ext/string.rb
object_identifier-0.6.0 lib/core_ext/string.rb
object_identifier-0.5.0 lib/core_ext/string.rb
object_identifier-0.4.1 lib/core_ext/string.rb
object_identifier-0.4.0 lib/core_ext/string.rb
object_identifier-0.3.0 lib/core_ext/string.rb
object_identifier-0.2.1 lib/core_ext/string.rb
object_identifier-0.2.0 lib/core_ext/string.rb