Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/bashly/extensions/string.rb
Instance Method Summary collapse
Instance Method Details
#indent(offset) ⇒ Object
5 6 7 8 |
# File 'lib/bashly/extensions/string.rb', line 5 def indent(offset) return self unless offset > 0 split("\n").indent(offset).join("\n") end |
#to_underscore ⇒ Object
16 17 18 |
# File 'lib/bashly/extensions/string.rb', line 16 def to_underscore dup.tap { |s| s.to_underscore! } end |
#to_underscore! ⇒ Object
10 11 12 13 14 |
# File 'lib/bashly/extensions/string.rb', line 10 def to_underscore! gsub!(/(.)([A-Z])/,'\1_\2') gsub!(' ', '_') downcase! end |