Sha256: a0b673a3343edac1cebdb6ada0adb3b3ced16c1ae100642b25cdee7aeed99a0e

Contents?: true

Size: 637 Bytes

Versions: 1

Compression:

Stored size: 637 Bytes

Contents

# frozen_string_literal: true

module GitDiff
  class Diff
    attr_reader :files

    def initialize
      @files = []
    end

    def <<(string)
      if file = File.from_string(string)
        add_file file
      else
        append_to_current_file string
      end
    end

    def stats
      @stats ||= Stats.total(collector)
    end

    private

    def collector
      GitDiff::StatsCollector::Rollup.new(files)
    end

    attr_accessor :current_file

    def add_file(file)
      self.current_file = file
      files << current_file
    end

    def append_to_current_file(line)
      current_file << line
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
git_diff-0.4.3 lib/git_diff/diff.rb