Sha256: 79ebaf3a06bedee10d5268d62718465f0e417a130dfc38d0d37e5521facebcd6

Contents?: true

Size: 1.26 KB

Versions: 7

Compression:

Stored size: 1.26 KB

Contents

== String#expand_tab

  require 'facets/string/expand_tab'

We will use this string as a basis for demonstration.

  tabs = <<-EOF.gsub(/^\s+\|/, '')
  |
  |\tOne tab
  | \tOne space and one tab
  |    \t Six spaces, a tab, and a space
  EOF

Expanding tabs 0.

  expected = <<-EOF.gsub(/^\s+\|/, '')
  |
  |One tab
  | One space and one tab
  |     Six spaces, a tab, and a space
  EOF

  tabs.expand_tabs(0).assert == expected

Expanding tabs 1.

  expected = <<-EOF.gsub(/^\s+\|/, '')
  |
  | One tab
  |  One space and one tab
  |      Six spaces, a tab, and a space
  EOF

  tabs.expand_tabs(1).assert == expected

Expanding tabs 4.

  expected = <<-EOF.gsub(/^\s+\|/, '')
  |
  |    One tab
  |    One space and one tab
  |         Six spaces, a tab, and a space
  EOF

  tabs.expand_tabs(4).assert == expected

Expanding tabs 8.

  expected = <<-EOF.gsub(/^\s+\|/, '')
  |
  |        One tab
  |        One space and one tab
  |         Six spaces, a tab, and a space
  EOF

  tabs.expand_tabs.assert == expected
  tabs.expand_tabs(8).assert == expected

Expanding tabs 16.

  expected = <<-EOF.gsub(/^\s+\|/, '')
  |
  |                One tab
  |                One space and one tab
  |                 Six spaces, a tab, and a space
  EOF

  tabs.expand_tabs(16).assert == expected

Version data entries

7 entries across 7 versions & 1 rubygems

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