class RSpecLive::FormattedText
Public Class Methods
new(text, options = {})
click to toggle source
# File lib/rspec-live/formatted_text.rb, line 3 def initialize(text, options = {}) @text = text @wrap = options[:wrap] @width = options[:width] @hanging_indent = options[:hanging_indent] || 0 end
Public Instance Methods
text()
click to toggle source
# File lib/rspec-live/formatted_text.rb, line 10 def text if @wrap wrap(@text, @width - @hanging_indent).split("\n").join("\n" + (" " * @hanging_indent)) else @text end end
Private Instance Methods
wrap(text, width)
click to toggle source
# File lib/rspec-live/formatted_text.rb, line 20 def wrap(text, width) text.scan(/\S.{0,#{width-2}}\S(?=\s|$)|\S+/).join("\n") end