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
-
#camelize(str) ⇒ Object
Converts
str
from an_underscored-or-dasherized_string to ACamelizedString. -
#deindent(str, leading_spaces: 6) ⇒ Object
Removes a number of leading whitespace for each input line.
-
#prettify(str) ⇒ Object
Improves indentation and spacing in
str
for readability in Byebug’s command prompt.
Instance Method Details
#camelize(str) ⇒ Object
Converts str
from an_underscored-or-dasherized_string to ACamelizedString.
11 12 13 |
# File 'lib/byebug/helpers/string.rb', line 11 def camelize(str) str.dup.split(/[_-]/).map(&:capitalize).join('') end |
#deindent(str, leading_spaces: 6) ⇒ Object
Note:
Might be unnecessary when Ruby 2.2 support is dropped and we can
Removes a number of leading whitespace for each input line.
use squiggly heredoc’s.
29 30 31 |
# File 'lib/byebug/helpers/string.rb', line 29 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.
19 20 21 |
# File 'lib/byebug/helpers/string.rb', line 19 def prettify(str) "\n" + deindent(str) + "\n" end |