class Shoulda::Matchers::Document

@private

Attributes

document[R]
indent[R]

Public Class Methods

new(document, indent: 0) click to toggle source
# File lib/shoulda/matchers/util/word_wrap.rb, line 16
def initialize(document, indent: 0)
  @document = document
  @indent = indent
end

Public Instance Methods

wrap() click to toggle source
# File lib/shoulda/matchers/util/word_wrap.rb, line 21
def wrap
  wrapped_paragraphs.map { |lines| lines.join("\n") }.join("\n\n")
end

Private Instance Methods

paragraphs() click to toggle source
# File lib/shoulda/matchers/util/word_wrap.rb, line 31
def paragraphs
  document.split(/\n{2,}/)
end
wrapped_paragraphs() click to toggle source
# File lib/shoulda/matchers/util/word_wrap.rb, line 35
def wrapped_paragraphs
  paragraphs.map do |paragraph|
    Paragraph.new(paragraph, indent: indent).wrap
  end
end