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::Fasta_numeric, Bio::Sequence::Format::Formatter::Fastq, 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
110 111 112 113 |
# File 'lib/bio/sequence/format.rb', line 110 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
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/bio/sequence/format.rb', line 118 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
90 91 92 |
# File 'lib/bio/sequence/format.rb', line 90 def self.output(sequence, = {}) self.new(sequence, ).output end |
Instance Method Details
#output ⇒ Object
generates output data
- Returns
-
String object
105 106 107 |
# File 'lib/bio/sequence/format.rb', line 105 def output raise NotImplementedError, 'should be implemented in subclass' end |