Class: GnCrossmap::ColumnCollector
- Inherits:
-
Object
- Object
- GnCrossmap::ColumnCollector
- Defined in:
- lib/gn_crossmap/column_collector.rb
Overview
Assemble data from CSV reader by checking column fields
Constant Summary collapse
- RANKS =
%i(kingdom subkingdom phylum subphylum superclass class subclass cohort superorder order suborder infraorder superfamily family subfamily tribe subtribe genus subgenus section species subspecies variety form).freeze
- SPECIES_RANKS =
%i(genus species subspecies variety form).freeze
Instance Method Summary collapse
- #id_name_rank(row) ⇒ Object
-
#initialize(fields) ⇒ ColumnCollector
constructor
A new instance of ColumnCollector.
Constructor Details
#initialize(fields) ⇒ ColumnCollector
Returns a new instance of ColumnCollector.
10 11 12 13 14 15 |
# File 'lib/gn_crossmap/column_collector.rb', line 10 def initialize(fields) @fields = fields err = "At least some of these fields must exist in " \ "the CSV header: '#{RANKS.join('\', \'')}'" raise GnCrossmapError, err if (RANKS - @fields).size == RANKS.size end |
Instance Method Details
#id_name_rank(row) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/gn_crossmap/column_collector.rb', line 17 def id_name_rank(row) @row = row id = @row[:taxonid] return nil if id.to_s.strip == "" rank = find_rank return nil unless rank name = assemble_name(rank) return nil unless name { id: id, name: name, rank: rank.to_s } end |