Sha256: f6bea046946f3856ad3e0d1296d6a64c3f1ab7155cd77b3c065f35bcf93c978b

Contents?: true

Size: 683 Bytes

Versions: 7

Compression:

Stored size: 683 Bytes

Contents

== String#tabto

  require 'facets/string/tabto'

String#tabto indeent lines relative to their current indentions. Using #tabto
on a single line behaves just like #tab.

  a = "xyz".tabto(2)
  a.assert ==  "  xyz"

  a = "    xyz".tabto(2)
  a.assert ==  "  xyz"

If the string has multiple lines, then each line will be indented
accordingly.

  a = "abc\nxyz".tabto(2)
  a.assert ==  "  abc\n  xyz"

Unlike #tab, the left margin of indention is determined by the first
non-blank line.

  a = "  abc\n    xyz".tabto(2)
  a.assert ==  "  abc\n    xyz"

If we add a blank line at the begining it will be the same.

  a = " \n  abc\n    xyz".tabto(2)
  a.assert ==  " \n  abc\n    xyz"

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
facets-3.0.0 demo/core/string/tabto.rdoc
facets-2.9.3 qed/core/string/tabto.rdoc
facets-2.9.2 qed/core/string/tabto.rdoc
facets-2.9.1 qed/core/string/tabto.rdoc
facets-2.9.0 qed/core/string/tabto.rdoc
facets-2.9.0.pre.2 qed/core/string/tabto.rdoc
facets-2.9.0.pre.1 qed/core/string/tabto.rdoc