Sha256: 367d2711e3ba16448bbd43fed6c7bb37e9321a69efc1878e06d2e5acb6ac9810
Contents?: true
Size: 419 Bytes
Versions: 4
Compression:
Stored size: 419 Bytes
Contents
class String # Indent left or right by n spaces. # (This used to be called #tab and aliased as #indent.) # # CREDIT: Gavin Sinclair, Trans, Tyler Rick def indent(n, c=' ') if n >= 0 gsub(/^/, c * n) else gsub(/^#{Regexp.escape(c)}{0,#{-n}}/, "") end end # Outdent just indents a negative number of spaces. # # CREDIT: Noah Gibbs def outdent(n) indent(-n) end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
facets-2.8.4 | lib/core/facets/string/indent.rb |
facets-2.8.3 | lib/core/facets/string/indent.rb |
facets-2.8.2 | lib/core/facets/string/indent.rb |
facets-2.8.1 | lib/core/facets/string/indent.rb |