Class: Bio::FlatFile::AutoDetect::RuleProc
- Inherits:
-
RuleTemplate
- Object
- RuleTemplate
- Bio::FlatFile::AutoDetect::RuleProc
- Defined in:
- lib/bio/io/flatfile/autodetection.rb
Overview
A autodetection rule that passes data to the proc object.
Instance Attribute Summary
Attributes inherited from RuleTemplate
#higher_priority_elements, #lower_priority_elements, #name
Instance Method Summary collapse
-
#dbclasses ⇒ Object
database classes (lazy evaluation).
-
#guess(text, meta) ⇒ Object
If given text (and/or meta information) is known, returns the database class.
-
#initialize(*dbclasses, &proc) ⇒ RuleProc
constructor
Creates a new instance.
Methods inherited from RuleTemplate
Constructor Details
#initialize(*dbclasses, &proc) ⇒ RuleProc
Creates a new instance.
199 200 201 202 203 204 205 |
# File 'lib/bio/io/flatfile/autodetection.rb', line 199 def initialize(*dbclasses, &proc) super() @proc = proc @dbclasses = nil @dbclasses_lazy = dbclasses @name = dbclasses.collect { |x| x.to_s }.join('|') end |
Instance Method Details
#dbclasses ⇒ Object
database classes (lazy evaluation)
208 209 210 211 212 213 |
# File 'lib/bio/io/flatfile/autodetection.rb', line 208 def dbclasses unless @dbclasses @dbclasses = @dbclasses_lazy.collect { |x| get_dbclass(x) } end @dbclasses end |
#guess(text, meta) ⇒ Object
If given text (and/or meta information) is known, returns the database class. Otherwise, returns nil or false.
Refer RuleTemplate#guess for meta.
220 221 222 |
# File 'lib/bio/io/flatfile/autodetection.rb', line 220 def guess(text, ) @proc.call(text) end |