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.



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

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)


263
264
265
# File 'lib/rio/matchrecord.rb', line 263

def always?()
  @always == true
end

#class_tailObject



256
257
258
# File 'lib/rio/matchrecord.rb', line 256

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

#init_always(reset = false) ⇒ Object



230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/rio/matchrecord.rb', line 230

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



259
260
261
262
# File 'lib/rio/matchrecord.rb', line 259

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)


269
270
271
272
273
274
275
# File 'lib/rio/matchrecord.rb', line 269

def match?(val,recno)
  #p "match?(#{val},#{recno}) #{self.inspect}"
  return @always unless @always.nil?
  as = nil
  ok = ((!@sel.nil? && (as = @sel.match?(val,recno))) && !(!@rej.nil? && @rej.match?(val,recno)))
  return (ok ? as : ok)
end

#never?Boolean

Returns:

  • (Boolean)


266
267
268
# File 'lib/rio/matchrecord.rb', line 266

def never?()
  @always == false
end

#only_one_fixnum?Boolean

Returns:

  • (Boolean)


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

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

#rangesObject



253
254
255
# File 'lib/rio/matchrecord.rb', line 253

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

#rangetopsObject



249
250
251
252
# File 'lib/rio/matchrecord.rb', line 249

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

#remove_passed_ranges(n) ⇒ Object



243
244
245
246
247
248
# File 'lib/rio/matchrecord.rb', line 243

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