Class: Bio::Sequence::Format::FormatterBase

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/sequence/format.rb

Overview

Formatter base class. Any formatter class should inherit this class.

Class Method Summary collapse

Instance Method Summary collapse

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, options = {})
  @sequence = sequence
  @options = 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, options = {})
  self.new(sequence, options).output
end

Instance Method Details

#outputObject

generates output data


Returns

String object

Raises:

  • (NotImplementedError)


105
106
107
# File 'lib/bio/sequence/format.rb', line 105

def output
  raise NotImplementedError, 'should be implemented in subclass'
end