module AuslibReport
Constants
- FOOTER
- TAG
Public Instance Methods
Source
# File lib/auslib_report.rb, line 86 def build_config_error SearchReport.config_error_card( tag: TAG, title: "library search", body_lines: [AuslibConfig.setup_hint], footer_parts: FOOTER ) end
Source
# File lib/auslib_report.rb, line 73 def build_fetch_error(query) SearchReport.fetch_error_card( tag: TAG, query: query, fallback_title: "library search", error_lines: [ "Trove search unavailable right now.", "Try: #{AuslibSearch.browse_url(query)}" ], footer_parts: FOOTER ) end
Source
# File lib/auslib_report.rb, line 39 def build_report(query:, total:, items:) if items.empty? return SearchReport.empty_report( tag: TAG, query: query, total: 0, empty_lines: [ "No Trove matches in books, newspapers, or images.", "Browse: #{AuslibSearch.browse_url(query)}" ], footer_parts: FOOTER, comma_count: true ) end SearchReport.results_report( tag: TAG, query: query, total: total, body_lines: items.each_with_index.map { |item, index| format_item_line(index + 1, item) }, footer_parts: FOOTER, comma_count: true ) end
Source
# File lib/auslib_report.rb, line 64 def build_usage SearchReport.usage_card( tag: TAG, title: "library search", usage_message: AuslibSearch.usage_message, footer_parts: FOOTER ) end
Source
# File lib/auslib_report.rb, line 25 def format_count(total) TextUtil.format_count(total, comma: true) end
Source
# File lib/auslib_report.rb, line 29 def format_item_line(index, item) meta = [item[:date], item[:kind]].map(&:to_s).reject(&:empty?) SearchReport.list_item_line( index: index, title: AuslibSearch.truncate_text(item[:title], AuslibConfig::MAX_TITLE_LENGTH), detail_parts: [item[:contributor].to_s.strip, meta.join(" ยท ")].reject(&:empty?), url: item[:url] ) end
Source
# File lib/auslib_report.rb, line 21 def heading_title(query, total) SearchReport.heading(query: query, total: total, comma_count: true) end