class MgNu::Genbank::Qualifier
Attributes
name[RW]
quoted[RW]
value[RW]
Public Class Methods
new(opts = {})
click to toggle source
create new Qualifier
object
# File lib/mgnu/genbank/qualifier.rb, line 8 def initialize(opts = {}) @name = opts.key?(:name) ? strip_quotes(opts[:name]).downcase : nil @value = opts.key?(:value) ? opts[:value] : nil @quoted = opts.key?(:quoted) ? opts[:quoted] : false end
Public Instance Methods
to_s()
click to toggle source
string representation
# File lib/mgnu/genbank/qualifier.rb, line 15 def to_s out = ("\n" + ' ' * 21) out << "/#{name}" if value out << '=' out << '"' if quoted # calculate max length for first line of qualifier value x = 79 - 21 - (name.length + 2) # length of name + equal sign x -= 1 if quoted if value.length > x first_line_max = nil x.downto(0).each do |i| if value[i].chr =~ /[^\w-]/ first_line_max = i break end end first_line_max ||= x out << value[0 .. first_line_max - 1] out << "\n" out << (' ' * 21 + value[first_line_max .. -1].print_multiline(79, :indent => 21).strip) else out << value end out << '"' if quoted end out end