module RadarReport
RadarReport โ IRC card formatting for BOM radar lookups. Public: build_report, build_usage, build_error Depends: irc_reply, irc_format, bom_radar_config Tests: test/lib/radar_report_test.rb
Constants
- FOOTER
- STYLE_TITLE
- TAG
Public Instance Methods
Source
# File lib/radar_report.rb, line 61 def build_error(message) IrcReply.error(tag: TAG, message: message) end
Source
# File lib/radar_report.rb, line 52 def build_not_found(place) IrcReply.card( tag: TAG, title: "not found", body_lines: ["Could not find #{place}."], footer_parts: FOOTER ) end
Source
# File lib/radar_report.rb, line 28 def build_report(place:, site:, map_lines:, town_summaries:, observed: nil, edge_note: nil) body = [] body.concat(Array(map_lines)) summary = Array(town_summaries).join(" ยท ") body << summary unless summary.empty? body << edge_note unless edge_note.to_s.strip.empty? IrcReply.card( tag: TAG, title: build_title(place: place, site: site, observed: observed), body_lines: body, footer_parts: FOOTER + [BomRadarFetch.loop_url(site[:product_id]).sub(%r{\Ahttps?://}, "")] ) end
Source
# File lib/radar_report.rb, line 20 def build_title(place:, site:, observed: nil) parts = [place.to_s.strip] site_label = "#{site[:name]} #{site[:range_km]} km" parts << site_label parts << observed.to_s.strip unless observed.to_s.strip.empty? parts.reject(&:empty?).join(" ยท ") end
Source
# File lib/radar_report.rb, line 43 def build_usage IrcReply.card( tag: TAG, title: "weather radar", body_lines: ["Usage: !radar <location> โ e.g. !radar elgin vale"], footer_parts: FOOTER ) end