Class: RSpecLive::FormattedText

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec-live/formatted_text.rb

Instance Method Summary collapse

Constructor Details

#initialize(text, options = {}) ⇒ FormattedText

Returns a new instance of FormattedText.



3
4
5
6
7
8
# 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

Instance Method Details

#textObject



10
11
12
13
14
15
16
# 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