Class: BioTable::NumericFilter
- Inherits:
-
Object
- Object
- BioTable::NumericFilter
- Defined in:
- lib/bio-table/filter.rb
Overview
FIXME: we should have a faster version too
Instance Method Summary collapse
-
#initialize(header) ⇒ NumericFilter
constructor
A new instance of NumericFilter.
- #method_missing(m, *args, &block) ⇒ Object
- #numeric(code, fields) ⇒ Object
Constructor Details
#initialize(header) ⇒ NumericFilter
Returns a new instance of NumericFilter.
153 154 155 |
# File 'lib/bio-table/filter.rb', line 153 def initialize header @header = header.map { |name| name.downcase } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/bio-table/filter.rb', line 168 def method_missing m, *args, &block if @header i = @header.index(m.to_s) if i != nil # p @header,i return @values[i] end raise "Unknown value (can not find column name '#{m}') in list '#{@header}'" end raise "Unknown method '#{m}'" end |
Instance Method Details
#numeric(code, fields) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/bio-table/filter.rb', line 157 def numeric code, fields values = LazyValues.new(fields) value = values # alias @values = values begin eval(code) rescue Exception $stderr.print "Failed to evaluate ",fields," with ",code,"\n" raise end end |