Class: BioTable::NumericFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/bio-table/filter.rb

Overview

FIXME: we should have a faster version too

Instance Method Summary collapse

Constructor Details

#initialize(header) ⇒ NumericFilter

Returns a new instance of NumericFilter.



140
141
142
# File 'lib/bio-table/filter.rb', line 140

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



155
156
157
158
159
160
161
162
163
164
165
# File 'lib/bio-table/filter.rb', line 155

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



144
145
146
147
148
149
150
151
152
153
154
# File 'lib/bio-table/filter.rb', line 144

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