class SuperDiff::RSpec::MatcherTextTemplate
Constants
- MAX_LINE_LENGTH
Attributes
tokens[R]
Public Class Methods
new() { |self| ... }
click to toggle source
# File lib/super_diff/rspec/matcher_text_template.rb, line 10 def initialize @tokens = [] if block_given? yield self end end
render(&block)
click to toggle source
# File lib/super_diff/rspec/matcher_text_template.rb, line 6 def self.render(&block) new(&block).to_s end
Public Instance Methods
add_break(*args, &block)
click to toggle source
# File lib/super_diff/rspec/matcher_text_template.rb, line 38 def add_break(*args, &block) add_token(Break, *args, &block) end
add_list_in_color(*args, &block)
click to toggle source
# File lib/super_diff/rspec/matcher_text_template.rb, line 34 def add_list_in_color(*args, &block) add_token(ColorizedList, *args, &block) end
add_text(*args, &block)
click to toggle source
# File lib/super_diff/rspec/matcher_text_template.rb, line 18 def add_text(*args, &block) add_token(PlainText, *args, &block) end
add_text_in_color(*args, &block)
click to toggle source
# File lib/super_diff/rspec/matcher_text_template.rb, line 22 def add_text_in_color(*args, &block) add_token(ColorizedText, *args, &block) end
add_text_in_multiline_mode(*args, &block)
click to toggle source
# File lib/super_diff/rspec/matcher_text_template.rb, line 30 def add_text_in_multiline_mode(*args, &block) add_token(PlainTextInMultilineMode, *args, &block) end
add_text_in_singleline_mode(*args, &block)
click to toggle source
# File lib/super_diff/rspec/matcher_text_template.rb, line 26 def add_text_in_singleline_mode(*args, &block) add_token(PlainTextInSinglelineMode, *args, &block) end
insert(*args, &block)
click to toggle source
# File lib/super_diff/rspec/matcher_text_template.rb, line 42 def insert(*args, &block) add_token(Insertion, *args, &block) end
length_of_first_paragraph()
click to toggle source
# File lib/super_diff/rspec/matcher_text_template.rb, line 46 def length_of_first_paragraph Csi.decolorize(to_string_in_singleline_mode). split(/\n\n/). first. length end
to_s(as_single_line: nil)
click to toggle source
# File lib/super_diff/rspec/matcher_text_template.rb, line 53 def to_s(as_single_line: nil) if length_of_first_paragraph > MAX_LINE_LENGTH || as_single_line == false to_string_in_multiline_mode elsif length_of_first_paragraph <= MAX_LINE_LENGTH || as_single_line == true to_string_in_singleline_mode end end
to_string_in_multiline_mode()
click to toggle source
# File lib/super_diff/rspec/matcher_text_template.rb, line 65 def to_string_in_multiline_mode tokens.map(&:to_string_in_multiline_mode).join end
to_string_in_singleline_mode()
click to toggle source
# File lib/super_diff/rspec/matcher_text_template.rb, line 61 def to_string_in_singleline_mode tokens.map(&:to_string_in_singleline_mode).join end
Private Instance Methods
add_token(klass, *args, &block)
click to toggle source
# File lib/super_diff/rspec/matcher_text_template.rb, line 73 def add_token(klass, *args, &block) tokens << klass.new(*args, &block) end