Sha256: 52858c83e36ac9efa137cd567922d8320e14f41e51bc1ee6d45cc182bfc83382

Contents?: true

Size: 450 Bytes

Versions: 3

Compression:

Stored size: 450 Bytes

Contents

module SubDiff
  class Collection < SimpleDelegator
    extend Forwardable
    include Enumerable

    attr_reader :string, :diffs

    def_delegators :diffs, :each, :size

    def initialize(string)
      @string = string
      @diffs = []
      super(string)
    end

    def changed?
      diffs.any?(&:changed?)
    end

    def push(diff)
      unless diff.empty?
        diffs << diff
        __setobj__(diffs.join)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sub_diff-1.0.4 lib/sub_diff/collection.rb
sub_diff-1.0.3 lib/sub_diff/collection.rb
sub_diff-1.0.2 lib/sub_diff/collection.rb