Class: Card::Content::Diff::LCS::ExcludeeIterator

Inherits:
Object
  • Object
show all
Defined in:
lib/card/content/diff/processor.rb

Overview

support class for LCS::Processor

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(list) ⇒ ExcludeeIterator

Returns a new instance of ExcludeeIterator.



128
129
130
131
132
# File 'lib/card/content/diff/processor.rb', line 128

def initialize list
  @list = list
  @index = 0
  @chunk_index = 0
end

Class Method Details

.old_and_new(old_excludees, new_excludees) ⇒ Object



121
122
123
124
125
126
# File 'lib/card/content/diff/processor.rb', line 121

def self.old_and_new old_excludees, new_excludees
  {
    old: new(old_excludees),
    new: new(new_excludees)
  }
end

Instance Method Details

#nextObject



138
139
140
141
142
143
144
145
146
# File 'lib/card/content/diff/processor.rb', line 138

def next
  if @index < @list.size &&
     @list[@index][:chunk_index] == @chunk_index
    res = @list[@index]
    @index += 1
    @chunk_index += 1
    res
  end
end

#scan_and_record(record_array) ⇒ Object



148
149
150
151
152
153
154
155
156
# File 'lib/card/content/diff/processor.rb', line 148

def scan_and_record record_array
  while (ex = self.next)
    if ex[:type] == :disjunction
      record_array << ex[:element]
    else
      yield ex[:element]
    end
  end
end

#word_stepObject



134
135
136
# File 'lib/card/content/diff/processor.rb', line 134

def word_step
  @chunk_index += 1
end