Class: Bio::GFF::GFF2::MetaData

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/db/gff.rb

Overview

Stores GFF2 meta-data.

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (MetaData) initialize(directive, data = nil)

Creates a new MetaData object



767
768
769
770
# File 'lib/bio/db/gff.rb', line 767

def initialize(directive, data = nil)
  @directive = directive
  @data = data
end

Instance Attribute Details

- (Object) data

data of this entry



777
778
779
# File 'lib/bio/db/gff.rb', line 777

def data
  @data
end

- (Object) directive

Directive. Usually, one of “feature-ontology”, “attribute-ontology”, or “source-ontology”.



774
775
776
# File 'lib/bio/db/gff.rb', line 774

def directive
  @directive
end

Class Method Details

+ (Object) parse(line)

parses a line



780
781
782
783
784
# File 'lib/bio/db/gff.rb', line 780

def self.parse(line)
  directive, data = line.chomp.split(/\s+/, 2)
  directive = directive.sub(/\A\#\#/, '') if directive
  self.new(directive, data)
end

Instance Method Details

- (Object) ==(other)

Returns true if self == other. Otherwise, returns false.



794
795
796
797
798
799
800
801
802
# File 'lib/bio/db/gff.rb', line 794

def ==(other)
  if self.class == other.class and
      self.directive == other.directive and
      self.data == other.data then
    true
  else
    false
  end
end

- (Object) to_s

string representation of this meta-data



787
788
789
790
791
# File 'lib/bio/db/gff.rb', line 787

def to_s
  d = @directive.to_s.gsub(/[\r\n]+/, ' ')
  v = ' ' + @data.to_s.gsub(/[\r\n]+/, ' ') unless @data.to_s.empty?
  "\#\##{d}#{v}\n"
end