Module: Manilla

Defined in:
lib/manilla/version.rb,
lib/manilla.rb,
lib/manilla/folder.rb,
lib/manilla/unfolder.rb

Overview

You know what versioning is, right?

Defined Under Namespace

Modules: Folder, Unfolder

Constant Summary collapse

VERSION =
'1.0.0'

Class Method Summary collapse

Class Method Details

.fold(text, maxwidth, delimiter, break_on = :char) ⇒ Object

Breaks long lines of text into multiple delimited representations.

Examples:

Fold text on character

Manilla.fold('Hello, world!', 8, "\r\n\s")
=> Hello, w
    orld!

Fold text on word

Manilla.fold('Hello, world!', 8, "\r\n\s", :word)
=> Hello,
    world!

Parameters:

  • text (String)

    The text to be folded

  • maxwidth (Integer)

    The maximum length of a line of text

  • delimiter (String)

    String used to denote line boundaries

  • break_on (Symbol) (defaults to: :char)

    Specifies whether to fold text on a character (‘:char`) or word (`:word`) (default: `:char`)



26
27
28
# File 'lib/manilla.rb', line 26

def self.fold(text, maxwidth, delimiter, break_on = :char)
  Manilla::Folder.call(text, maxwidth, delimiter, break_on)
end

.unfold(text, delimiter) ⇒ Object

Moves from a folded delimited representation to a single line representation by treating delimiters as blank strings.

Examples:

Unfold text

text = "Hello, world!"

folded_text = Manilla.fold(text, 8, "\r\n", :word)
=> Hello,
    world!

Manilla.unfold(folded_text, "\r\n")
=> Hello, world!

Parameters:

  • text (String)

    Text to be unfolded

  • delimiter (String)

    String used to denote line boundaries



47
48
49
# File 'lib/manilla.rb', line 47

def self.unfold(text, delimiter)
  Manilla::Unfolder.call(text, delimiter)
end