class Bio::FlatFile::AutoDetect::RuleTemplate
Template of a single rule of autodetection
Attributes
dbclasses[R]
database classes
higher_priority_elements[R]
higher priority elements
lower_priority_elements[R]
lower priority elements
name[RW]
unique name of the element
Public Class Methods
[](*arg)
click to toggle source
Creates a new element.
# File lib/bio/io/flatfile/autodetection.rb, line 38 def self.[](*arg) self.new(*arg) end
new()
click to toggle source
Creates a new element.
# File lib/bio/io/flatfile/autodetection.rb, line 43 def initialize @higher_priority_elements = RulesArray.new @lower_priority_elements = RulesArray.new @name = nil end
Public Instance Methods
guess(text, meta)
click to toggle source
If given text (and/or meta information) is known, returns the database class. Otherwise, returns nil or false.
text will be a String. meta will be a Hash. meta may contain following keys. :path => pathname, filename or uri.
# File lib/bio/io/flatfile/autodetection.rb, line 76 def guess(text, meta) nil end
is_prior_to(elem)
click to toggle source
self is prior to the elem.
# File lib/bio/io/flatfile/autodetection.rb, line 50 def is_prior_to(elem) return nil if self == elem elem.higher_priority_elements << self self.lower_priority_elements << elem true end
Private Instance Methods
get_dbclass(obj)
click to toggle source
Gets database class from given object. Current implementation is: if obj is kind of String, regarded as a constant. Otherwise, returns obj as is.
# File lib/bio/io/flatfile/autodetection.rb, line 94 def get_dbclass(obj) obj.kind_of?(String) ? str2const(obj) : obj end
str2const(str)
click to toggle source
Gets constant from constant name given as a string.
# File lib/bio/io/flatfile/autodetection.rb, line 82 def str2const(str) const = Object str.split(/\:\:/).each do |x| const = const.const_get(x) end const end