Class: RIO::Match::Record::SelList
Overview
for a sellist nil indicates no call was made, so nothing selected empty indicates a call was made, so all selected contents should be checked for matches if contents are removed the list should become nil, not empty
Class Method Summary collapse
Instance Method Summary collapse
- #always? ⇒ Boolean
- #create_sel(therio, arg) ⇒ Object
- #delete_at(index) ⇒ Object
-
#initialize(therio, args) ⇒ SelList
constructor
A new instance of SelList.
- #inspect ⇒ Object
- #match?(val, recno) ⇒ Boolean
- #never? ⇒ Boolean
- #only_one_fixnum? ⇒ Boolean
- #ranges ⇒ Object
- #remove_passed_ranges(n) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(therio, args) ⇒ SelList
Returns a new instance of SelList.
129 130 131 132 133 134 135 136 137 138 |
# File 'lib/rio/matchrecord.rb', line 129 def initialize(therio,args) if args.nil? @list = nil else @list = [] args.each do |arg| @list << create_sel(therio,arg) end end end |
Class Method Details
.create(therio, args) ⇒ Object
150 151 152 |
# File 'lib/rio/matchrecord.rb', line 150 def self.create(therio,args) new(therio,args) unless args.nil? end |
Instance Method Details
#always? ⇒ Boolean
179 |
# File 'lib/rio/matchrecord.rb', line 179 def always?() !@list.nil? && @list.empty? end |
#create_sel(therio, arg) ⇒ Object
166 167 168 |
# File 'lib/rio/matchrecord.rb', line 166 def create_sel(therio,arg) Match::Record.create(therio,arg) end |
#delete_at(index) ⇒ Object
146 147 148 149 |
# File 'lib/rio/matchrecord.rb', line 146 def delete_at(index) @list.delete_at(index) @list = nil if @list.empty? end |
#inspect ⇒ Object
139 140 141 |
# File 'lib/rio/matchrecord.rb', line 139 def inspect @list.inspect end |
#match?(val, recno) ⇒ Boolean
169 170 171 172 173 174 175 176 177 178 |
# File 'lib/rio/matchrecord.rb', line 169 def match?(val,recno) return false unless @list return true if @list.empty? as = nil al = @list.detect { |sel| as = sel.match?(val,recno) as } return as if al return false end |
#never? ⇒ Boolean
180 |
# File 'lib/rio/matchrecord.rb', line 180 def never?() @list.nil? end |
#only_one_fixnum? ⇒ Boolean
143 144 145 |
# File 'lib/rio/matchrecord.rb', line 143 def only_one_fixnum?() @list && @list.size == 1 && @list[0].kind_of?(Match::Record::Integer) end |
#ranges ⇒ Object
153 154 155 |
# File 'lib/rio/matchrecord.rb', line 153 def ranges() @list.nil? ? [] : @list.select { |sel| sel.kind_of?(Record::Range) } end |
#remove_passed_ranges(n) ⇒ Object
156 157 158 159 160 161 162 163 164 165 |
# File 'lib/rio/matchrecord.rb', line 156 def remove_passed_ranges(n) return nil if @list.nil? return self if @list.empty? newlist = [] @list.each do |sel| newlist << sel unless sel.kind_of?(Match::Record::Range) and sel.val.max < n end @list = (newlist.empty? ? nil : newlist) if newlist.length != @list.length @list.nil? ? nil : self end |
#size ⇒ Object
142 |
# File 'lib/rio/matchrecord.rb', line 142 def size() @list.size unless @list.nil? end |