Sha256: 7b6cfb9a3a385780f9e1a4281f19e345ae252bf16215fd9718ebea62d7576851

Contents?: true

Size: 762 Bytes

Versions: 310

Compression:

Stored size: 762 Bytes

Contents

# -*- ruby encoding: utf-8 -*-

# A block is an operation removing, adding, or changing a group of items.
# Basically, this is just a list of changes, where each change adds or
# deletes a single item. Used by bin/ldiff.
class Diff::LCS::Block
  attr_reader :changes, :insert, :remove

  def initialize(chunk)
    @changes = []
    @insert = []
    @remove = []

    chunk.each do |item|
      @changes << item
      @remove << item if item.deleting?
      @insert << item if item.adding?
    end
  end

  def diff_size
    @insert.size - @remove.size
  end

  def op
    case [@remove.empty?, @insert.empty?]
    when [false, false]
      '!'
    when [false, true]
      '-'
    when [true, false]
      '+'
    else # [true, true]
      '^'
    end
  end
end

Version data entries

310 entries across 287 versions & 87 rubygems

Version Path
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/diff-lcs-1.3/lib/diff/lcs/block.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/diff-lcs-1.3/lib/diff/lcs/block.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/diff-lcs-1.3/lib/diff/lcs/block.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/diff-lcs-1.3/lib/diff/lcs/block.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/diff-lcs-1.3/lib/diff/lcs/block.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/diff-lcs-1.3/lib/diff/lcs/block.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/diff-lcs-1.3/lib/diff/lcs/block.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/diff-lcs-1.3/lib/diff/lcs/block.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/diff-lcs-1.3/lib/diff/lcs/block.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/diff-lcs-1.3/lib/diff/lcs/block.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/diff-lcs-1.3/lib/diff/lcs/block.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/diff-lcs-1.3/lib/diff/lcs/block.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/diff-lcs-1.3/lib/diff/lcs/block.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/diff-lcs-1.3/lib/diff/lcs/block.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/diff-lcs-1.3/lib/diff/lcs/block.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/diff-lcs-1.3/lib/diff/lcs/block.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/diff-lcs-1.3/lib/diff/lcs/block.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/diff-lcs-1.3/lib/diff/lcs/block.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/diff-lcs-1.3/lib/diff/lcs/block.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/diff-lcs-1.3/lib/diff/lcs/block.rb