Module: Wrapomatic

Defined in:
lib/wrapomatic.rb,
lib/wrapomatic/line.rb,
lib/wrapomatic/version.rb,
lib/wrapomatic/wrapper.rb,
lib/wrapomatic/line/processor.rb,
lib/wrapomatic/line/processor/base.rb,
lib/wrapomatic/line/processor/primary.rb,
lib/wrapomatic/line/processor/remainder.rb

Overview

Let’s line wrap some strings!

Defined Under Namespace

Classes: Line, Wrapper

Constant Summary collapse

VERSION =

The current Wrapomatic version

"0.3.0"

Class Method Summary collapse

Class Method Details

.wrap(text, options = {}) ⇒ String

Wraps the given text with optional indentation and width

Parameters:

  • text (String)

    the text blob to wrap

  • options (Hash) (defaults to: {})

    the options with which to wrap the text

Options Hash (options):

  • :indents (Integer) — default: 0

    the number of indentation levels to use for wrapping the text

  • :columns (Integer) — default: 80

    the number of columes to which the text should be wrapped

Returns:

  • (String)

    the wrapped text



21
22
23
24
25
# File 'lib/wrapomatic.rb', line 21

def self.wrap(text, options = {})
  indents = options[:indents] || 0
  columns = options[:columns] || 80
  Wrapper.new(text, indents, columns).wrapped
end