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

Inherits:
Object
  • Object
show all
Defined in:
card/lib/card/content/diff/l_c_s/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.



130
131
132
133
134
# File 'card/lib/card/content/diff/l_c_s/processor.rb', line 130

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

Class Method Details

.old_and_new(old_excludees, new_excludees) ⇒ Object



123
124
125
126
127
128
# File 'card/lib/card/content/diff/l_c_s/processor.rb', line 123

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

Instance Method Details

#nextObject



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

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



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

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



136
137
138
# File 'card/lib/card/content/diff/l_c_s/processor.rb', line 136

def word_step
  @chunk_index += 1
end