Class: Match::Otu::MergeResults

Inherits:
Object
  • Object
show all
Defined in:
lib/match/otu/merge_results.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tn_results:, otu_results:) ⇒ MergeResults

Returns a new instance of MergeResults.

Parameters:

  • tn_results (Array<Hash>)

    Match::Otu::TaxonName#call results

  • otu_results (Array<Hash>)

    Match::Otu::MorphospeciesName#call results, same size and input order as tn_results



19
20
21
22
# File 'lib/match/otu/merge_results.rb', line 19

def initialize(tn_results:, otu_results:)
  @tn_results = tn_results
  @otu_results = otu_results
end

Instance Attribute Details

#otu_resultsObject (readonly)

Returns the value of attribute otu_results.



14
15
16
# File 'lib/match/otu/merge_results.rb', line 14

def otu_results
  @otu_results
end

#tn_resultsObject (readonly)

Returns the value of attribute tn_results.



14
15
16
# File 'lib/match/otu/merge_results.rb', line 14

def tn_results
  @tn_results
end

Instance Method Details

#callArray<Hash>

Returns:

  • (Array<Hash>)


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/match/otu/merge_results.rb', line 25

def call
  tn_results.zip(otu_results).map do |tn, otu|
    if tn[:matched]
      if otu[:matched]
        tn.merge(match_source: 'both', ambiguous: true)
      else
        tn.merge(match_source: 'taxon_name')
      end
    elsif otu[:matched]
      otu.merge(scientific_name: tn[:scientific_name], match_source: 'otu')
    else
      tn.merge(match_source: nil)
    end
  end
end