Module: TypeMaterials::CatalogHelper

Defined in:
app/helpers/type_materials/catalog_helper.rb

Instance Method Summary collapse

Instance Method Details

#type_material_catalog_label(type_material, verbose = false) ⇒ Object

Return text only, no HTML. To be used in paper catalogs, this is to be human readable.

If we need italics or bold use Markdown, and we will compile after that


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/helpers/type_materials/catalog_helper.rb', line 7

def type_material_catalog_label(type_material, verbose = false) # Possibly parameterize biocurations: true, repository: true, identifiers: true
  t = type_material

  if t.nil? && verbose # Anticipate rendering in paper
    return '[TODO: Add type material]'
  elsif t.nil?
    return nil
  end

  co = t.collection_object
  ce = co.collecting_event

  v = []

  # Holotype male, adult, INHS 12312, deposited: <repoo name>. <verbatim_label>.

  if co.ranged_lot_category.present?
    v.push t.type_type.capitalize + "(n= #{ranged_lot_range(co.ranged_lot_category)})"
  else
    v.push t.type_type.capitalize + (co.total > 1 ? " (n= #{co.total})" : '')
  end

  v.push co.biocuration_classes.collect{|a| a.name.downcase}.join(', ').presence

  # TODO: add verbose warning when missing any identifier
  # TODO: add option(?) to render all identifiers
  v.push label_for_identifier(
    co.identifiers.prefer('Identifier::Local::CatalogNumber').first
  )

  if d = label_for_repository(co.repository)
    v.push "deposited at: #{d}"
  else
    if verbose
      v.push '[TODO: Repository NOT PROVIDED]'
    end
  end

  v.push type_material_collecting_event_label(type_material.collection_object.collecting_event, verbose)
  v.compact.join('; ')
end

#type_material_collecting_event_label(collecting_event, verbose = false) ⇒ String

Returns Must return a string, if no value then the wqrning is returned.

Returns:

  • (String)

    Must return a string, if no value then the wqrning is returned



51
52
53
54
55
56
57
58
59
60
61
# File 'app/helpers/type_materials/catalog_helper.rb', line 51

def type_material_collecting_event_label(collecting_event, verbose = false)
  missing = '[TODO: A document (preferred) or verbatim label in a collecting event must be provided]'
  if ce = collecting_event
    if ce.document_label
      return ::Utilities::Strings.linearize(ce.document_label)
    elsif ce.verbatim_label
      return  ::Utilities::Strings.linearize(ce.verbatim_label)
    end
  end
  verbose ? missing : nil
end