Sha256: 59c9873fc20c6ba413765849ee88eff6be054436946aa00b6f32f91fb1af5a65

Contents?: true

Size: 761 Bytes

Versions: 5007

Compression:

Stored size: 761 Bytes

Contents

# frozen_string_literal: true

# 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

5,007 entries across 4,958 versions & 53 rubygems

Version Path
mux_ruby-3.20.0 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/lib/diff/lcs/block.rb
mux_ruby-3.19.0 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/lib/diff/lcs/block.rb
moneykit-0.1.15 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/lib/diff/lcs/block.rb
moneykit-0.1.14 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/lib/diff/lcs/block.rb
mux_ruby-3.18.0 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/lib/diff/lcs/block.rb
moneykit-0.1.13 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/lib/diff/lcs/block.rb
moneykit-0.1.12 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/lib/diff/lcs/block.rb
moneykit-0.1.11 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/lib/diff/lcs/block.rb
mux_ruby-3.17.0 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/lib/diff/lcs/block.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.4.4/lib/diff/lcs/block.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.4.4/lib/diff/lcs/block.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.4.4/lib/diff/lcs/block.rb
moneykit-0.1.10 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/lib/diff/lcs/block.rb
moneykit-0.1.9 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/lib/diff/lcs/block.rb
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/lib/diff/lcs/block.rb
mux_ruby-3.15.0 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/lib/diff/lcs/block.rb
avalara_sdk-24.2.29 vendor/bundle/ruby/2.7.0/gems/diff-lcs-1.5.0/lib/diff/lcs/block.rb
mux_ruby-3.14.0 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/lib/diff/lcs/block.rb
moneykit-0.1.6 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/lib/diff/lcs/block.rb
moneykit-0.1.5 vendor/bundle/ruby/3.2.0/gems/diff-lcs-1.5.0/lib/diff/lcs/block.rb