Sha256: 8229bfa3cf1487b411ef4101f2f3a6b2268a08e1083ae236d18541f77c874d12

Contents?: true

Size: 822 Bytes

Versions: 3

Compression:

Stored size: 822 Bytes

Contents

module Byebug
  module Helpers
    #
    # Utilities for interaction with strings
    #
    module StringHelper
      #
      # Converts +str+ from an_underscored-or-dasherized_string to
      # ACamelizedString.
      #
      def camelize(str)
        str.dup.split(/[_-]/).map(&:capitalize).join('')
      end

      #
      # Improves indentation and spacing in +str+ for readability in Byebug's
      # command prompt.
      #
      def prettify(str)
        "\n" + deindent(str) + "\n"
      end

      #
      # Removes a number of leading whitespace for each input line.
      #
      # @note Might be unnecessary when Ruby 2.2 support is dropped and we can
      # use squiggly heredoc's.
      #
      def deindent(str, leading_spaces: 6)
        str.gsub(/^ {#{leading_spaces}}/, '')
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 3 rubygems

Version Path
dirwatch-0.0.2 vendor/bundle/ruby/2.3.0/gems/byebug-9.1.0/lib/byebug/helpers/string.rb
tdiary-5.0.6 vendor/bundle/gems/byebug-9.1.0/lib/byebug/helpers/string.rb
byebug-9.1.0 lib/byebug/helpers/string.rb