module IrcAscii
IrcAscii — traditional IRC / Ibis / mIRC-script ASCII frame art (plain text). Public: degree_line, graph_bar, nick_bar, fserve_slot, ibis_box, margin_bar Depends: (none) Tests: test/lib/irc_ascii_test.rb
Constants
- DEGREE_CHAR
- GRAPH_END_CHAR
- GRAPH_OFF_CHAR
- GRAPH_ON_CHAR
Public Instance Methods
Source
# File lib/irc_ascii.rb, line 16 def degree_line(width:, ends: 1, mid: 2) inner = [width.to_i - 2, 0].max "#{DEGREE_CHAR * ends}#{DEGREE_CHAR * inner}#{DEGREE_CHAR * ends}" end
Source
# File lib/irc_ascii.rb, line 35 def fserve_slot(label: "TAG", width: 40) inner = [width.to_i - 4, 4].max text = " #{label.to_s.strip.upcase} " padded = text.ljust(inner)[0, inner] [ "#" * width, "##{padded.center(inner)}#", "#" * width ] end
Source
# File lib/irc_ascii.rb, line 21 def graph_bar(filled:, total:, on: GRAPH_ON_CHAR, off: GRAPH_OFF_CHAR, ends: GRAPH_END_CHAR) total_i = total.to_i return ends * 2 if total_i <= 0 filled_i = [[filled.to_i, 0].max, total_i].min bar = (on * filled_i) + (off * (total_i - filled_i)) "#{ends}#{bar}#{ends}" end
Source
# File lib/irc_ascii.rb, line 46 def ibis_box(label: "TAG", width: 24) inner = [width.to_i - 4, 4].max text = label.to_s.strip.upcase [ " .#{"-" * inner}.", " | #{text.ljust(inner - 1)}|", " .#{"-" * inner}'" ] end
Source
# File lib/irc_ascii.rb, line 56 def margin_bar(label: "TAG", width: 56) label_text = label.to_s.strip.upcase block = "###" gap = [width - (block.length * 2) - label_text.length - 4, 8].max dots = "." * gap "[#{block}#{dots}] #{label_text} [#{dots}#{block}]" end
Source
# File lib/irc_ascii.rb, line 30 def nick_bar(width: 40) inner = [width.to_i - 1, 1].max "#{GRAPH_ON_CHAR}#{"-" * inner}" end