Class: Bio::Sequence::Format::FormatterBase
- Defined in:
- lib/bio/sequence/format.rb
Overview
Formatter base class. Any formatter class should inherit this class.
Direct Known Subclasses
Bio::Sequence::Format::Formatter::Fasta, Bio::Sequence::Format::Formatter::Fasta_ncbi, Bio::Sequence::Format::Formatter::Raw, NucFormatter::Embl, NucFormatter::Genbank
Class Method Summary collapse
-
.output(sequence, options = {}) ⇒ Object
- Returns a formatterd string of the given sequence — Arguments: * (required) sequence: Bio::Sequence object * (optional) options: a Hash object Returns
-
String object.
Instance Method Summary collapse
-
#initialize(sequence, options = {}) ⇒ FormatterBase
constructor
creates a new formatter object for output.
-
#output ⇒ Object
- generates output data — Returns
-
String object.
Constructor Details
#initialize(sequence, options = {}) ⇒ FormatterBase
creates a new formatter object for output
100 101 102 103 |
# File 'lib/bio/sequence/format.rb', line 100 def initialize(sequence, = {}) @sequence = sequence @options = end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object (private)
any unknown methods are delegated to the sequence object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/bio/sequence/format.rb', line 108 def method_missing(sym, *args, &block) #:nodoc: begin @sequence.__send__(sym, *args, &block) rescue NoMethodError => evar lineno = __LINE__ - 2 file = __FILE__ bt_here = [ "#{file}:#{lineno}:in \`__send__\'", "#{file}:#{lineno}:in \`method_missing\'" ] if bt_here == evar.backtrace[0, 2] then bt = evar.backtrace[2..-1] evar = evar.class.new("undefined method \`#{sym.to_s}\' for #{self.inspect}") evar.set_backtrace(bt) end raise(evar) end end |
Class Method Details
.output(sequence, options = {}) ⇒ Object
Returns a formatterd string of the given sequence
Arguments:
-
(required) sequence: Bio::Sequence object
-
(optional) options: a Hash object
- Returns
-
String object
80 81 82 |
# File 'lib/bio/sequence/format.rb', line 80 def self.output(sequence, = {}) self.new(sequence, ).output end |
Instance Method Details
#output ⇒ Object
generates output data
- Returns
-
String object
95 96 97 |
# File 'lib/bio/sequence/format.rb', line 95 def output raise NotImplementedError, 'should be implemented in subclass' end |