module RssReport
Constants
- STYLE_BANNER
- TAG
Public Instance Methods
Source
# File lib/rss_report.rb, line 33 def compact_item_body(item) title = item[:title].to_s description = item[:description].to_s.strip body = if description.empty? || description_redundant_with_title?(title, description) title else "#{title} — #{description}" end link = item[:link].to_s.strip body = IrcFormat.meta_join(body, link) unless link.empty? body end
Source
# File lib/rss_report.rb, line 21 def description_redundant_with_title?(title, description) norm_title = TextUtil.squish(title).downcase norm_description = TextUtil.squish(description).downcase return false if norm_description.empty? norm_description == norm_title end
Source
# File lib/rss_report.rb, line 29 def feed_heading(feed) feed["title"].to_s end
Source
# File lib/rss_report.rb, line 73 def format_feed_preview(feed, items) body_lines = items.each_with_index.map { |item, index| format_preview_item_line(index + 1, item) } count_label = items.length == 1 ? "1 item" : "#{items.length} items" [ rss_banner(feed_heading(feed)), body_lines.join("\n"), IrcFormat.report_footer("rss", feed["title"], count_label) ].join("\n") end
Source
# File lib/rss_report.rb, line 48 def format_item_card(feed, item) "#{rss_banner(feed_heading(feed))} #{compact_item_body(item)}" end
Source
# File lib/rss_report.rb, line 52 def format_list(feeds, interval_min:) lines = feeds.each_with_index.map do |feed, index| line = "#{index + 1}. #{feed['title']} — #{feed['url']}" filter = feed["link_filter"].to_s.strip line = "#{line} — filter: #{filter}" unless filter.empty? line end body = lines.empty? ? "No feeds subscribed." : lines.join("\n") count_label = feeds.length == 1 ? "1 feed" : "#{feeds.length} feeds" [ rss_banner("Subscribed feeds"), body, IrcFormat.report_footer("rss", count_label, "#{interval_min} min refresh") ].join("\n") end
Source
# File lib/rss_report.rb, line 69 def format_preview_item_line(index, item) "#{index}. #{compact_item_body(item)}" end