Class: PatienceDiff::FormattingContext

Inherits:
Object
  • Object
show all
Defined in:
lib/patience_diff/formatting_context.rb

Overview

Delegate object yielded by the #format method.

Instance Method Summary collapse

Constructor Details

#initialize(differ, formatter) ⇒ FormattingContext

Returns a new instance of FormattingContext.



6
7
8
9
10
# File 'lib/patience_diff/formatting_context.rb', line 6

def initialize(differ, formatter)
  @differ = differ
  @formatter = formatter
  @out = StringIO.new
end

Instance Method Details

#files(left_file, right_file) ⇒ Object



12
13
14
# File 'lib/patience_diff/formatting_context.rb', line 12

def files(left_file, right_file)
  @out.print @differ.diff_files(left_file, right_file, @formatter)
end

#formatObject



24
25
26
# File 'lib/patience_diff/formatting_context.rb', line 24

def format
  @out.string
end

#namesObject



32
33
34
# File 'lib/patience_diff/formatting_context.rb', line 32

def names
  @formatter.names
end

#orphan(sequence, name = nil, timestamp = nil) ⇒ Object



20
21
22
# File 'lib/patience_diff/formatting_context.rb', line 20

def orphan(sequence, name=nil, timestamp=nil)
  @out.print @formatter.render_orphan(sequence, name, timestamp)
end

#sequences(left, right, left_name = nil, right_name = nil, left_timestamp = nil, right_timestamp = nil) ⇒ Object



16
17
18
# File 'lib/patience_diff/formatting_context.rb', line 16

def sequences(left, right, left_name=nil, right_name=nil, left_timestamp=nil, right_timestamp=nil)
  @out.print @differ.diff_sequences(left, right, left_name, right_name, left_timestamp, right_timestamp, @formatter)
end

#titleObject



28
29
30
# File 'lib/patience_diff/formatting_context.rb', line 28

def title
  @formatter.title
end