Class: String

### Home Classes Methods

### In Files

- lib/turn/core_ext.rb

### Parent

Object

### Methods

- #indent
- #tab
- #tabto

### Files

- History.txt
- LICENSE.txt
- Release.txt
- Version.txt

### Class/Module Index

Quicksearch

- Turn
- Turn::Colorize
- Turn::Command
- Turn::Configuration
- Turn::Controller
- Turn::CrossRunner
- Turn::CueReporter
- Turn::DotReporter
- Turn::IsoRunner
- Turn::MarshalReporter
- Turn::MiniRunner
- Turn::OutlineReporter
- Turn::PrettyReporter
- Turn::ProgressReporter
- Turn::Reporter
- Turn::SoloRunner
- Turn::TestCase
- Turn::TestMethod
- Turn::TestRunner
- Turn::TestSuite
- Turn::ToptenDecorator
- Test
- Test::Unit
- Test::Unit::Failure
- Object
- String

No matching classes.

# String

Borrowed methods from Ruby Facets.

### Public Instance Methods

indent(n, c=' ') click to toggle source

Indent left or right by n spaces. (This used to be called tab and aliased as indent.)

    # File lib/turn/core_ext.rb, line 22
    def indent(n, c=' ')
      if n >= 0
        gsub(/^/, c * n)
      else
        gsub(/^#{Regexp.escape(c)}{0,#{-n}}/, "")
      end
    end

tab(n) click to toggle source

Aligns each line n spaces.

    # File lib/turn/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/turn/core_ext.rb, line 12
    def tabto(n)
      if self =~ /^( *)\S/
        indent(n - $1.length)
      else
        self
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.