Class: DiffParser::DiffFilesCollection
- Inherits:
-
Object
- Object
- DiffParser::DiffFilesCollection
- Includes:
- Enumerable
- Defined in:
- lib/diff_parser/diff_files_collection.rb
Instance Attribute Summary collapse
-
#diff ⇒ Object
readonly
Returns the value of attribute diff.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #each {|current_file| ... } ⇒ Object
-
#initialize(diff, options) ⇒ DiffFilesCollection
constructor
A new instance of DiffFilesCollection.
- #raw_lines ⇒ Object
Constructor Details
#initialize(diff, options) ⇒ DiffFilesCollection
Returns a new instance of DiffFilesCollection.
7 8 9 10 |
# File 'lib/diff_parser/diff_files_collection.rb', line 7 def initialize(diff, ) @options = @diff = diff end |
Instance Attribute Details
#diff ⇒ Object (readonly)
Returns the value of attribute diff.
5 6 7 |
# File 'lib/diff_parser/diff_files_collection.rb', line 5 def diff @diff end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/diff_parser/diff_files_collection.rb', line 5 def @options end |
Instance Method Details
#each {|current_file| ... } ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/diff_parser/diff_files_collection.rb', line 16 def each current_file = nil file_number = 0 raw_lines.each_with_index do |raw_line, idx| next if raw_line.skip_line? if raw_line.info? if current_file yield current_file file_number += 1 end current_file = DiffParser::File.new(raw_line.full_line, diff, file_number) current_file.type = raw_lines[idx + 1].type elsif fold_file?(current_file) if [:full] == current_file.path || [:full] == true current_file.push_line(raw_line, idx) else current_file.folded! current_file.lines.empty? and (current_file.lines = [DiffLine.new(current_file.path, 'fold', nil, nil, 0, nil)]) end else current_file.push_line(raw_line, idx) end end yield current_file unless current_file.nil? end |