Class: Bio::FlatFile::AutoDetect::RuleRegexp2

Inherits:
RuleRegexp show all
Defined in:
lib/bio/io/flatfile/autodetection.rb

Overview

A autodetection rule to use more than two regular expressions. If given string matches one of the regular expressions, returns the database class.

Instance Attribute Summary

Attributes inherited from RuleTemplate

#dbclasses, #higher_priority_elements, #lower_priority_elements, #name

Instance Method Summary collapse

Methods inherited from RuleRegexp

#dbclasses

Methods inherited from RuleTemplate

[], #is_prior_to

Constructor Details

#initialize(dbclass, *regexps) ⇒ RuleRegexp2

Creates a new instance.



180
181
182
183
# File 'lib/bio/io/flatfile/autodetection.rb', line 180

def initialize(dbclass, *regexps)
  super(dbclass, nil)
  @regexps = regexps
end

Instance Method Details

#guess(text, meta) ⇒ Object

If given text matches one of the regexp, returns the database class. Otherwise, returns nil or false. meta is ignored.



188
189
190
191
192
193
# File 'lib/bio/io/flatfile/autodetection.rb', line 188

def guess(text, meta)
  @regexps.each do |re|
    return dbclass if re =~ text
  end
  nil
end