class String
Borrowed methods from Ruby Facets.
Public Instance Methods
indent(n, c=' ')
click to toggle source
tab(n)
click to toggle source
Aligns each line n spaces.
# File lib/tapout/core_ext.rb, line 6 def tab(n) gsub(/^ */, ' ' * n) end
tabto(n)
click to toggle source
Preserves relative tabbing. The first non-empty line ends up with n spaces before nonspace.
# File lib/tapout/core_ext.rb, line 12 def tabto(n) if self =~ /^( *)\S/ indent(n - $1.length) else self end end