Class: Diff::LCS::Block

### Home Classes Methods

### In Files

- lib/diff/lcs/block.rb

### Parent

Object

### Methods

- ::new
- #diff_size
- #op

### Files

- Manifest.txt
- README.rdoc
- COPYING.txt
- artistic.txt

### Class/Module Index

Quicksearch

- Diff
- Diff::LCS
- Diff::LCS::BalancedCallbacks
- Diff::LCS::Block
- Diff::LCS::Change
- Diff::LCS::ContextChange
- Diff::LCS::ContextDiffCallbacks
- Diff::LCS::DefaultCallbacks
- Diff::LCS::DiffCallbacks
- Diff::LCS::HTMLDiff
- Diff::LCS::HTMLDiff::Callbacks
- Diff::LCS::Hunk
- Diff::LCS::Ldiff
- Diff::LCS::SDiffCallbacks
- Diff::LCS::SequenceCallbacks
- Array
- String

No matching classes.

# Diff::LCS::Block

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.

### Attributes

changes[R]
insert[R]
remove[R]

### Public Class Methods

new(chunk) click to toggle source

    # File lib/diff/lcs/block.rb, line 8
    def initialize(chunk)
      @changes = []
      @insert = []
      @remove = []

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

### Public Instance Methods

diff_size() click to toggle source

    # File lib/diff/lcs/block.rb, line 20
    def diff_size
      @insert.size - @remove.size
    end

op() click to toggle source

    # File lib/diff/lcs/block.rb, line 24
    def op
      case [@remove.empty?, @insert.empty?]
      when [false, false]
        '!'
      when [false, true]
        '-'
      when [true, false]
        '+'
      else # [true, true]
        '^'
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.