class Shoulda::Matchers::Paragraph
@private
Attributes
indent[R]
paragraph[R]
Public Class Methods
new(paragraph, indent: 0)
click to toggle source
# File lib/shoulda/matchers/util/word_wrap.rb, line 55 def initialize(paragraph, indent: 0) @paragraph = Text.new(paragraph) @indent = indent end
Public Instance Methods
wrap()
click to toggle source
# File lib/shoulda/matchers/util/word_wrap.rb, line 60 def wrap if paragraph.indented? lines elsif paragraph.list_item? wrap_list_item else wrap_generic_paragraph end end
Private Instance Methods
combine_list_item_lines(lines)
click to toggle source
# File lib/shoulda/matchers/util/word_wrap.rb, line 84 def combine_list_item_lines(lines) lines.reduce([]) do |combined_lines, line| if line.list_item? combined_lines << line else combined_lines.last << (' ' + line).squeeze(' ') end combined_lines end end
combine_paragraph_into_one_line()
click to toggle source
# File lib/shoulda/matchers/util/word_wrap.rb, line 104 def combine_paragraph_into_one_line paragraph.gsub(/\n/, ' ') end
lines()
click to toggle source
# File lib/shoulda/matchers/util/word_wrap.rb, line 80 def lines paragraph.split("\n").map { |line| Text.new(line) } end
wrap_generic_paragraph()
click to toggle source
# File lib/shoulda/matchers/util/word_wrap.rb, line 100 def wrap_generic_paragraph Line.new(combine_paragraph_into_one_line, indent: indent).wrap end
wrap_lines(lines)
click to toggle source
# File lib/shoulda/matchers/util/word_wrap.rb, line 96 def wrap_lines(lines) lines.map { |line| Line.new(line, indent: indent).wrap } end
wrap_list_item()
click to toggle source
# File lib/shoulda/matchers/util/word_wrap.rb, line 76 def wrap_list_item wrap_lines(combine_list_item_lines(lines)) end