module WhatsonReport
Render town event search results as an Ibis-style reply card.
Constants
- STYLE_BANNER
Public Instance Methods
Source
# File lib/whatson_report.rb, line 33 def build_report(events, parsed) town = parsed[:town].to_s if events.empty? return IrcReply.card( tag: "WHATSON", title: banner_title(town), body_lines: [ "No upcoming events found in quick search.", "Browse: #{WhatsonSearch.build_search_url(town)}" ], footer_parts: [TextUtil.title_words(town), "verify on council site"], heading_style: STYLE_BANNER ) end IrcReply.card( tag: "WHATSON", title: banner_title(town), body_lines: events.each_with_index.map { |event, index| format_event_line(index + 1, event) }, footer_parts: footer_parts(events.length, town), heading_style: STYLE_BANNER ) end
Source
# File lib/whatson_report.rb, line 19 def format_event_line(index, event) parts = [event[:title].to_s.strip] parts << event[:date].to_s.strip unless event[:date].to_s.strip.empty? parts << event[:location].to_s.strip unless event[:location].to_s.strip.empty? line = parts.reject(&:empty?).join(" โ ") url = event[:url].to_s.strip url.empty? ? "#{index}. #{line}" : "#{index}. #{line} (#{url})" end