module AlaSpeciesReport
Constants
- STYLE_TITLE
Public Instance Methods
Source
# File lib/ala_species_report.rb, line 23 def body_lines(match, description: nil) lines = [] common = match[:common_name].to_s.strip lines << common unless common.empty? taxonomy = taxonomy_line(match) lines << taxonomy if match[:occurrence_count].to_i.positive? && !taxonomy.empty? paragraph = description.to_s.strip unless paragraph.empty? paragraph.split("\n").each do |line| line = line.strip lines << line unless line.empty? end end lines << occurrence_line(match) lines end
Source
# File lib/ala_species_report.rb, line 43 def format(query, match, description: nil) if match.nil? return IrcReply.card( tag: "ALA", title: query.to_s, body_lines: ["No species found."], footer_parts: ["species search", "Atlas of Living Australia"], heading_style: STYLE_TITLE ) end IrcReply.card( tag: "ALA", title: match[:name], body_lines: body_lines(match, description: description), footer_parts: ["Atlas of Living Australia", "biodiversity.org.au"], heading_style: STYLE_TITLE ) end
Source
# File lib/ala_species_report.rb, line 11 def occurrence_line(match) rank = match[:rank].to_s.strip rank = "Species" if rank.empty? count = match[:occurrence_count].to_i "#{rank.capitalize} ยท #{count} occurrence records" end
Source
# File lib/ala_species_report.rb, line 18 def taxonomy_line(match) parts = [match[:kingdom], match[:family]].map { |value| value.to_s.strip }.reject(&:empty?) parts.join(" ยท ") end