Class: RIO::Match::Record::SelRej

Inherits:
Object
  • Object
show all
Defined in:
lib/rio/matchrecord.rb

Instance Method Summary collapse

Constructor Details

#initialize(therio, sel_args, rej_args) ⇒ SelRej

Returns a new instance of SelRej.



185
186
187
188
189
# File 'lib/rio/matchrecord.rb', line 185

def initialize(therio,sel_args,rej_args)
  @sel = SelList.create(therio,sel_args)
  @rej = SelList.create(therio,rej_args)
  @always = init_always()
end

Instance Method Details

#always?Boolean

Returns:

  • (Boolean)


226
227
228
# File 'lib/rio/matchrecord.rb', line 226

def always?()
  @always == true
end

#class_tailObject



219
220
221
# File 'lib/rio/matchrecord.rb', line 219

def class_tail
  self.class.to_s.sub(/^.+::/,'')
end

#init_always(reset = false) ⇒ Object



193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/rio/matchrecord.rb', line 193

def init_always(reset=false)
  if @sel.nil? and @rej.nil?
    !reset
  elsif @rej.nil? and @sel.always?
    true
  elsif @sel.nil?
    false
  elsif !@rej.nil? and @rej.always?
    false
  else
    nil
  end
end

#inspectObject



222
223
224
225
# File 'lib/rio/matchrecord.rb', line 222

def inspect
  sprintf("#<%s:0x%08x @always=%s @sel=%s @rej=%s>",self.class_tail,self.object_id,@always.inspect,
          @sel.inspect,@rej.inspect)
end

#match?(val, recno) ⇒ Boolean

Returns:

  • (Boolean)


232
233
234
235
236
237
# File 'lib/rio/matchrecord.rb', line 232

def match?(val,recno)
  return @always if @always
  as = nil
  ok = ((@sel && (as = @sel.match?(val,recno))) && !(@rej && @rej.match?(val,recno)))
  return (ok ? as : ok)
end

#never?Boolean

Returns:

  • (Boolean)


229
230
231
# File 'lib/rio/matchrecord.rb', line 229

def never?()
  @always == false
end

#only_one_fixnum?Boolean

Returns:

  • (Boolean)


190
191
192
# File 'lib/rio/matchrecord.rb', line 190

def only_one_fixnum?()
  @rej.nil? && @sel && @sel.only_one_fixnum?
end

#rangesObject



216
217
218
# File 'lib/rio/matchrecord.rb', line 216

def ranges()
  (@sel.nil? ? [] : @sel.ranges) + (@rej.nil? ? [] : @rej.ranges)
end

#rangetopsObject



212
213
214
215
# File 'lib/rio/matchrecord.rb', line 212

def rangetops()
  rtops = ranges.map { |r| r.val.max }.sort.uniq
  rtops.empty? ? nil : rtops
end

#remove_passed_ranges(n) ⇒ Object



206
207
208
209
210
211
# File 'lib/rio/matchrecord.rb', line 206

def remove_passed_ranges(n)
  @sel = @sel.remove_passed_ranges(n) unless @sel.nil?
  @rej = @rej.remove_passed_ranges(n) unless @rej.nil?
  @always = init_always(true)
  self
end