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
swift-pyrite-0.1.0 vendor/bundle/ruby/2.0.0/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb
suzuko-0.1.8 vendor/bundle/ruby/2.0.0/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb
suzuko-0.1.7 vendor/bundle/ruby/2.0.0/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb
logstash-input-beats-0.9.2 vendor/jruby/1.9/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb
logstash-input-beats-0.9.1 vendor/jruby/1.9/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb
mastermind_adeybee-0.1.4 vendor/bundle/ruby/2.2.0/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb
mastermind_adeybee-0.1.3 vendor/bundle/ruby/2.2.0/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb
mastermind_adeybee-0.1.2 vendor/bundle/ruby/2.2.0/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb
mastermind_adeybee-0.1.1 vendor/bundle/ruby/2.2.0/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb
sublimetheme-1.0.1 path/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb
sublimetheme-1.0.0 path/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb
geminfo-0.1.0 path/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb
scoot-0.0.4 .bundle/gems/ruby/2.2.0/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb
slimkeyfy-0.0.4 vendor/bundle/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb