Sha256: ec222c6ca59a0852e173be8116b5e642ecef235fd8b45888d97a615e46ee9ddf

Contents?: true

Size: 738 Bytes

Versions: 2

Compression:

Stored size: 738 Bytes

Contents

module PrettyDiff
  class Chunk
    attr_reader :diff, :meta_info, :lines, :contents

    def initialize(diff, meta_info, contents)
      @diff = diff
      @meta_info = meta_info
      @contents = contents
      @lines = find_lines
    end

    def line_numbers
      @_line_numbers ||= LineNumbers.new(diff, meta_info)
    end

  private

    def find_lines
      [].tap do |lines|
        contents.split(/\r?\n|\r/).each do |line_str|
          line = Line.new(self, line_str)
          next if line.ignored?
          lines << line
          line_numbers.act_on_line(line)
          line.left_number = line_numbers.left_column.last
          line.right_number = line_numbers.right_column.last
        end
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pretty_diff-2.0.1 lib/pretty_diff/chunk.rb
pretty_diff-2.0.0 lib/pretty_diff/chunk.rb