Class: BioTable::TextualFilter

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) ⇒ TextualFilter

Returns a new instance of TextualFilter.



109
110
111
# File 'lib/bio-table/filter.rb', line 109

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



124
125
126
127
128
129
130
131
132
133
134
# File 'lib/bio-table/filter.rb', line 124

def method_missing m, *args, &block
  if @header 
    i = @header.index(m.to_s)
    if i != nil
      # p @header,i
      return @fields[i] 
    end
    raise "Unknown field (can not find column name '#{m}') in list '#{@header}'"
  end
  raise "Unknown method '#{m}'"
end

Instance Method Details

#textual(code, tablefields) ⇒ Object



113
114
115
116
117
118
119
120
121
122
123
# File 'lib/bio-table/filter.rb', line 113

def textual code, tablefields
  field = tablefields.dup
  fields = field # alias
  @fields = fields
  begin
    eval(code)
  rescue Exception
    $stderr.print "Failed to evaluate ",fields," with ",code,"\n"
    raise 
  end
end