Class: Bio::FlatFile::AutoDetect::RuleRegexp2
- Inherits:
-
RuleRegexp
- Object
- RuleTemplate
- RuleRegexp
- Bio::FlatFile::AutoDetect::RuleRegexp2
- 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
-
#guess(text, meta) ⇒ Object
If given text matches one of the regexp, returns the database class.
-
#initialize(dbclass, *regexps) ⇒ RuleRegexp2
constructor
Creates a new instance.
Methods inherited from RuleRegexp
Methods inherited from RuleTemplate
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, ) @regexps.each do |re| return dbclass if re =~ text end nil end |