module DomainTldReport
IRC reply cards for TLD catalogue search.
Constants
- MAX_RESULTS
- STYLE_BANNER
- TAG
Public Instance Methods
Source
# File lib/domain_tld_report.rb, line 49 def empty(query:) IrcReply.card( tag: TAG, title: "#{query} ยท no matches", body_lines: ["No TLDs matched #{query}"], footer_parts: ["Porkbun public pricing"], heading_style: STYLE_BANNER ) end
Source
# File lib/domain_tld_report.rb, line 31 def format(query:, matches:, total:) if matches.empty? return empty(query: query) end title = heading_title(query, matches, total) body_lines = match_lines(matches) footer_parts = footer_meta(total: total, shown: matches.length) IrcReply.card( tag: TAG, title: title, body_lines: body_lines, footer_parts: footer_parts, heading_style: STYLE_BANNER ) end
Source
# File lib/domain_tld_report.rb, line 59 def heading_title(query, matches, total) if total == 1 && matches.first[:tld] == query match = matches.first status = match[:supported] ? "available" : "not available" ".#{query} ยท #{status}" else count = total == 1 ? "1 match" : "#{total} matches" "#{query} ยท #{count}" end end
Source
# File lib/domain_tld_report.rb, line 23 def invalid IrcReply.error( tag: TAG, message: "That does not look like a valid TLD search.", heading_style: STYLE_BANNER ) end
Source
# File lib/domain_tld_report.rb, line 70 def match_lines(matches) rows = matches.map do |match| { label: ".#{match[:tld]}", value: match_value(match) } end ReplyLayout.align_colon_body(rows) end
Source
# File lib/domain_tld_report.rb, line 80 def match_value(match) return "not supported" unless match[:supported] parts = [] parts << "register #{match[:register]}" if match[:register] parts << "renew #{match[:renew]}" if match[:renew] parts.join(" ยท ") end
Source
# File lib/domain_tld_report.rb, line 15 def usage IrcReply.error( tag: TAG, message: "Give me a TLD to search, e.g. !tld photo or !tld com", heading_style: STYLE_BANNER ) end