Module: TypeMaterials::CatalogHelper
- Defined in:
- app/helpers/type_materials/catalog_helper.rb
Instance Method Summary collapse
-
#catalog_object_locality_label(collection_object) ⇒ Object
TODO: move to collection object catalog helper when that is developed leverage DwC index methods.
-
#type_material_catalog_label(type_material, verbose = false) ⇒ Object
Return text only, no HTML.
-
#type_material_collecting_event_label(collecting_event, verbose = false) ⇒ String
Must return a string, if no value then the wqrning is returned.
Instance Method Details
#catalog_object_locality_label(collection_object) ⇒ Object
TODO: move to collection object catalog helper when that is developed
leverage DwC index methods
56 57 58 59 60 61 62 63 64 65 |
# File 'app/helpers/type_materials/catalog_helper.rb', line 56 def catalog_object_locality_label(collection_object) o = collection_object.dwc_occurrence [ o.country, o.stateProvince, o.county, o.verbatimLocality, ].compact.join(': ') end |
#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 48 49 50 51 52 |
# 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 if l = type_material_collecting_event_label(ce, verbose) v.push l else v.push catalog_object_locality_label(co) end 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.
69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/helpers/type_materials/catalog_helper.rb', line 69 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 |