Class: Catalog::Nomenclature::PaperCatalog

Inherits:
Catalog::Nomenclature show all
Defined in:
lib/catalog/nomenclature/paper_catalog.rb

Overview

Paper style comprehansive checklist

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Catalog::Nomenclature

#names

Constructor Details

#initialize(classification_scope: nil, project_id: nil, rank_filter: nil, otu_filter: nil, taxon_name_filter: nil, accepted_only: false, type_information: false, distribution: false, otu_contents: false) ⇒ PaperCatalog

Returns a new instance of PaperCatalog.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/catalog/nomenclature/paper_catalog.rb', line 74

def initialize(
  classification_scope: nil,
  project_id: nil,
  rank_filter: nil,
  otu_filter: nil,
  taxon_name_filter: nil,
  accepted_only: false,
  type_information: false,
  distribution: false,
  otu_contents: false)

  @classification_scope = classification_scope
  @project_id = project_id
  @rank_filter = rank_filter.to_s.downcase.split('|')
  @otu_filter = otu_filter
  @taxon_name_filter = taxon_name_filter
  @accepted_only = accepted_only
  @type_information = type_information
  @distribution = distribution
  @otu_contents = otu_contents
  @taxon_name_ids = []
  @otu_id_filter_array = otu_filter_array

  #Main logic
  @results_hash = {names: {}, sources: {}}
  @position = 0

  build_the_list
end

Instance Attribute Details

#accepted_only ⇒ String or null

Returns:

  • (String or null)


35
36
37
# File 'lib/catalog/nomenclature/paper_catalog.rb', line 35

def accepted_only
  @accepted_only
end

#classification_scope ⇒ String

Returns:

  • (String)


10
11
12
# File 'lib/catalog/nomenclature/paper_catalog.rb', line 10

def classification_scope
  @classification_scope
end

#distribution ⇒ String or null

Returns:

  • (String or null)


45
46
47
# File 'lib/catalog/nomenclature/paper_catalog.rb', line 45

def distribution
  @distribution
end

#otu_contents ⇒ String or null

Returns:

  • (String or null)


50
51
52
# File 'lib/catalog/nomenclature/paper_catalog.rb', line 50

def otu_contents
  @otu_contents
end

#otu_filter ⇒ String or null

Returns:

  • (String or null)


25
26
27
# File 'lib/catalog/nomenclature/paper_catalog.rb', line 25

def otu_filter
  @otu_filter
end

#otu_id_filter_array ⇒ Hash

Returns:

  • (Hash)


62
63
64
# File 'lib/catalog/nomenclature/paper_catalog.rb', line 62

def otu_id_filter_array
  @otu_id_filter_array
end

#project_id ⇒ String

Returns:

  • (String)


15
16
17
# File 'lib/catalog/nomenclature/paper_catalog.rb', line 15

def project_id
  @project_id
end

#rank_filter ⇒ String or null

Returns:

  • (String or null)


20
21
22
# File 'lib/catalog/nomenclature/paper_catalog.rb', line 20

def rank_filter
  @rank_filter
end

#results_hash ⇒ Hash

Returns:

  • (Hash)


72
73
74
# File 'lib/catalog/nomenclature/paper_catalog.rb', line 72

def results_hash
  @results_hash
end

#source_hash ⇒ Object

Returns list of sources



67
68
69
# File 'lib/catalog/nomenclature/paper_catalog.rb', line 67

def source_hash
  @source_hash
end

#sources_hash ⇒ Hash

Returns:

  • (Hash)


67
# File 'lib/catalog/nomenclature/paper_catalog.rb', line 67

attr_accessor :source_hash

#taxon_name_filter ⇒ String or null

Returns:

  • (String or null)


30
31
32
# File 'lib/catalog/nomenclature/paper_catalog.rb', line 30

def taxon_name_filter
  @taxon_name_filter
end

#taxon_name_ids ⇒ Hash

Returns:

  • (Hash)


57
58
59
# File 'lib/catalog/nomenclature/paper_catalog.rb', line 57

def taxon_name_ids
  @taxon_name_ids
end

#type_information ⇒ String or null

Returns:

  • (String or null)


40
41
42
# File 'lib/catalog/nomenclature/paper_catalog.rb', line 40

def type_information
  @type_information
end

Instance Method Details

#build_the_list ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/catalog/nomenclature/paper_catalog.rb', line 104

def build_the_list
  results_hash
  return {} if project_id.nil?
  return {} if classification_scope.blank? && otu_filter.blank? && taxon_name_filter.blank?

  taxon = classification_scope.blank? ? nil : TaxonName.find(classification_scope.to_i)

  if !taxon_name_filter.blank?
    tn_ids = taxon_name_filter.to_s.split('|').map(&:to_i)
    TaxonName.where(id: tn_ids).each do |t|
      add_taxon_to_results(t) if t.id == t.cached_valid_taxon_name_id
    end
  elsif !taxon.nil?
    #   ancestors = get_ancestors(taxon)
    # descendants = get_descendants(taxon)
  end
  if results_hash.names.count > 0 && accepted_only.to_s != 'true'
    # synonyms = get_synonyms
  end
  if taxon_name_ids.count > 0
    # statuses = get_taxon_name_classifications
    # relationships = get_taxon_name_relationships
  end
end