Sha256: 7ae0d3a929c9c9f2f13044fb6127f3ec0ed1121b54ccd0492ee4af5214c4c364
Contents?: true
Size: 428 Bytes
Versions: 2
Compression:
Stored size: 428 Bytes
Contents
class String # Indent left or right by n spaces. # (This used to be called #tab and aliased as #indent.) def indent(n) if n >= 0 gsub(/^/, ' ' * n) else gsub(/^ {0,#{-n}}/, "") end end # Preserves relative tabbing. # The first non-empty line ends up with n spaces before nonspace. def tabto(n) if self =~ /^( *)\S/ indent(n - $1.length) else self end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
clio-0.2.0 | lib/clio/facets/string.rb |
clio-0.3.0 | lib/clio/facets/string.rb |