Sha256: 368afd9fcaba3f50389a86bcea12a1049250f7185d92e935364a7555e85f1356

Contents?: true

Size: 632 Bytes

Versions: 1

Compression:

Stored size: 632 Bytes

Contents

module SubDiff
  class DiffCollection
    include Enumerable

    def initialize(diffs = [])
      @diffs = []
      diffs.each { |diff| self << diff }
    end

    def <<(diff)
      if diff.changed? || !diff.empty?
        @diffs << diff
        @to_s = nil
      end
      self
    end

    def each(&block)
      @diffs.each(&block)
    end

    def method_missing(*args, &block)
      to_s.send(*args, &block)
    end

    def respond_to_missing?(method, include_private)
      to_s.respond_to?(method, include_private)
    end

    def size
      @diffs.size
    end

    def to_s
      @to_s ||= @diffs.join
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sub_diff-0.0.0 lib/sub_diff/diff_collection.rb