Class: Bio::FlatFile::AutoDetect::RuleTemplate

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

Overview

Template of a single rule of autodetection

Direct Known Subclasses

RuleDebug, RuleProc, RuleRegexp, RuleSpecial

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (RuleTemplate) initialize

Creates a new element.



43
44
45
46
47
# File 'lib/bio/io/flatfile/autodetection.rb', line 43

def initialize
  @higher_priority_elements = RulesArray.new
  @lower_priority_elements  = RulesArray.new
  @name = nil
end

Instance Attribute Details

- (Object) dbclasses (readonly)

database classes



63
64
65
# File 'lib/bio/io/flatfile/autodetection.rb', line 63

def dbclasses
  @dbclasses
end

- (Object) higher_priority_elements (readonly)

higher priority elements



58
59
60
# File 'lib/bio/io/flatfile/autodetection.rb', line 58

def higher_priority_elements
  @higher_priority_elements
end

- (Object) lower_priority_elements (readonly)

lower priority elements



60
61
62
# File 'lib/bio/io/flatfile/autodetection.rb', line 60

def lower_priority_elements
  @lower_priority_elements
end

- (Object) name

unique name of the element



66
67
68
# File 'lib/bio/io/flatfile/autodetection.rb', line 66

def name
  @name
end

Class Method Details

+ (Object) [](*arg)

Creates a new element.



38
39
40
# File 'lib/bio/io/flatfile/autodetection.rb', line 38

def self.[](*arg)
  self.new(*arg)
end

Instance Method Details

- (Object) guess(text, meta)

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.



76
77
78
# File 'lib/bio/io/flatfile/autodetection.rb', line 76

def guess(text, meta)
  nil
end

- (Object) is_prior_to(elem)

self is prior to the elem.



50
51
52
53
54
55
# 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