Class: Diff::Display::Data
- Inherits:
-
Array
- Object
- Array
- Diff::Display::Data
- Defined in:
- lib/diff/display/data_structure.rb
Instance Method Summary collapse
- #debug ⇒ Object
-
#initialize ⇒ Data
constructor
A new instance of Data.
- #to_diff ⇒ Object
Constructor Details
#initialize ⇒ Data
Returns a new instance of Data.
4 5 6 |
# File 'lib/diff/display/data_structure.rb', line 4 def initialize super end |
Instance Method Details
#debug ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/diff/display/data_structure.rb', line 32 def debug demodularize = Proc.new {|obj| obj.class.name[/\w+$/]} each do |diff_block| print "-" * 40, ' ', demodularize.call(diff_block) puts puts diff_block.map {|line| # "%5d" % line.old_number + "%8s" % "[#{line.old_number || '.'} #{line.new_number || '.'}]" + " [#{demodularize.call(line)}#{'(i)' if line.inline_changes?}]" + line }.join("\n") puts "-" * 40, ' ' end nil end |
#to_diff ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/diff/display/data_structure.rb', line 8 def to_diff diff = "" each do |block| block.each do |line| line_str = line.(nil, nil) case line when HeaderLine diff << "#{line_str}\n" when UnModLine diff << " #{line_str}\n" when SepLine diff << "\n" when AddLine diff << "+#{line_str}\n" when RemLine diff << "-#{line_str}\n" when NonewlineLine diff << line_str end end end diff.chomp end |