Method: Wrapomatic::Wrapper#text
- Defined in:
-
lib/wrapomatic/wrapper.rb,
lib/wrapomatic/wrapper.rb
Returns the text to wrap.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/wrapomatic/wrapper.rb', line 18 class Wrapper attr_reader :text, :lines, :indents, :columns # @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 def initialize(text, indents = 0, columns = 80) @text, @indents, @columns = text, indents, columns @lines = [] spit_some_mad_fire end # The text wrapped to the desired indentation level and column cutoff # # @return [String] the wrapped text, joined by newlines def wrapped @lines.join("\n") end private def spit_some_mad_fire @lines = unwrapped_lines.map {|line| Line.new(line, indents, columns).wrapped }.flatten end def unwrapped_lines text.split("\n") end end |