module ChartsReport
ChartsReport โ IRC card formatting for !charts replies. Public: format_entry_line, build, error Tests: test/lib/charts_report_test.rb
Constants
- SOURCE
- TAG
Public Instance Methods
Source
# File lib/charts_report.rb, line 28 def build(country_name:, chart_date:, entries:) if entries.empty? return IrcReply.card( tag: TAG, title: "#{country_name} ยท weekly chart", body_lines: ["No chart entries found."], footer_parts: [SOURCE] ) end title = "#{country_name} ยท weekly top #{entries.length}" title = "#{title} ยท #{chart_date}" if chart_date IrcReply.card( tag: TAG, title: title, body_lines: entries.map { |entry| format_entry_line(**entry) }, footer_parts: [entries.length.to_s, "tracks", SOURCE] ) end
Source
# File lib/charts_report.rb, line 49 def error(message) IrcReply.error(tag: TAG, message: message) end
Source
# File lib/charts_report.rb, line 20 def format_change(change) value = change.to_s.strip return "NEW" if value.match?(/\ANEW\z/i) return value if value.match?(/\A[+-]\d+\z/) value.empty? ? "=" : value end
Source
# File lib/charts_report.rb, line 15 def format_entry_line(position:, change:, label:) move = format_change(change) "#{position}. #{label} ยท #{move}" end