class Wrapomatic::Wrapper
Wrap several lines
@!attribute [r] text
@return [String] the text to wrap
@!attribute [r] lines
@return [Array<String>] the text after wrapping as individual lines
@!attribute [r] indents
@return [Integer] the indentation level
@!attribute [r] columns
@return [Integer] the column cutoff
Attributes
columns[R]
indents[R]
lines[R]
text[R]
Public Class Methods
new(text, indents = 0, columns = 80)
click to toggle source
@param text [String] the text to wrap
@param indents [Integer] the level to which each line should be
indented
@param columns [Integer] the column to which each line should be
wrapped
# File lib/wrapomatic/wrapper.rb, line 28 def initialize(text, indents = 0, columns = 80) @text, @indents, @columns = text, indents, columns @lines = [] spit_some_mad_fire end
Public Instance Methods
wrapped()
click to toggle source
The text wrapped to the desired indentation level and column cutoff
@return [String] the wrapped text, joined by newlines
# File lib/wrapomatic/wrapper.rb, line 37 def wrapped @lines.join("\n") end
Private Instance Methods
spit_some_mad_fire()
click to toggle source
# File lib/wrapomatic/wrapper.rb, line 42 def spit_some_mad_fire @lines = unwrapped_lines.map {|line| Line.new(line, indents, columns).wrapped }.flatten end
unwrapped_lines()
click to toggle source
# File lib/wrapomatic/wrapper.rb, line 48 def unwrapped_lines text.split("\n") end