Module: Byebug::Helpers::StringHelper

Included in:
Command, InfoCommand::FileCommand, Runner
Defined in:
lib/byebug/helpers/string.rb

Overview

Utilities for interaction with strings

Instance Method Summary collapse

Instance Method Details

#camelize(str) ⇒ Object

Converts str from an_underscored-or-dasherized_string to ACamelizedString.



13
14
15
# File 'lib/byebug/helpers/string.rb', line 13

def camelize(str)
  str.dup.split(/[_-]/).map(&:capitalize).join("")
end

#deindent(str, leading_spaces: 6) ⇒ Object

Removes a number of leading whitespace for each input line.



28
29
30
# File 'lib/byebug/helpers/string.rb', line 28

def deindent(str, leading_spaces: 6)
  str.gsub(/^ {#{leading_spaces}}/, "")
end

#prettify(str) ⇒ Object

Improves indentation and spacing in str for readability in Byebug’s command prompt.



21
22
23
# File 'lib/byebug/helpers/string.rb', line 21

def prettify(str)
  "\n" + deindent(str) + "\n"
end