Class: Bio::FlatFile::AutoDetect::RuleRegexp

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

Overview

A autodetection rule to use a regular expression

Direct Known Subclasses

RuleRegexp2

Instance Attribute Summary

Attributes inherited from RuleTemplate

#higher_priority_elements, #lower_priority_elements, #name

Instance Method Summary collapse

Methods inherited from RuleTemplate

[], #is_prior_to

Constructor Details

#initialize(dbclass, re) ⇒ RuleRegexp

Creates a new instance.


145
146
147
148
149
150
151
# File 'lib/bio/io/flatfile/autodetection.rb', line 145

def initialize(dbclass, re)
  super()
  @re = re
  @name = dbclass.to_s
  @dbclass = nil
  @dbclass_lazy = dbclass
end

Instance Method Details

#dbclassesObject

returns database classes


163
164
165
# File 'lib/bio/io/flatfile/autodetection.rb', line 163

def dbclasses
  [ dbclass ]
end

#guess(text, meta) ⇒ Object

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


170
171
172
# File 'lib/bio/io/flatfile/autodetection.rb', line 170

def guess(text, meta)
  @re =~ text ? dbclass : nil
end