class Cheatly::Renderer

Public Instance Methods

block_code(code, language = nil) click to toggle source
# File lib/cheatly/renderer.rb, line 9
def block_code(code, language = nil)
  code = code.each_line
  code = code.map { |l| "    #{l}" }
  "\n#{code.join}\n"
end
codespan(code) click to toggle source
# File lib/cheatly/renderer.rb, line 15
def codespan(code)
  "`#{code}`"
end
double_emphasis(text) click to toggle source
# File lib/cheatly/renderer.rb, line 31
def double_emphasis(text)
  text.bold
end
emphasis(text) click to toggle source
# File lib/cheatly/renderer.rb, line 35
def emphasis(text)
  text.underline
end
header(title, level) click to toggle source
# File lib/cheatly/renderer.rb, line 19
def header(title, level)
  sep =
    case level
    when 1 then '='
    when 2 then '+'
    when 3 then '-'
    else ''
    end

  "\n#{title.bold}\n#{(sep * title.length).bold}\n"
end
image(color, bg_color, text) click to toggle source
# File lib/cheatly/renderer.rb, line 57
def image(color, bg_color, text)
  text = text.colorize(color: color.to_sym)
  text = text.colorize(background: bg_color.to_sym) if bg_color

  text
end
linebreak() click to toggle source
# File lib/cheatly/renderer.rb, line 43
def linebreak
  "\n"
end
list(content, list_type) click to toggle source
# File lib/cheatly/renderer.rb, line 47
def list(content, list_type)
 content
end
list_item(content, list_type) click to toggle source
# File lib/cheatly/renderer.rb, line 51
def list_item(content, list_type)
  lines = content.each_line
  lines = lines.map { |l| "   #{l}" }
  " - #{lines.join.strip}\n"
end
normal_text(text) click to toggle source
# File lib/cheatly/renderer.rb, line 5
def normal_text(text)
  text
end
paragraph(text) click to toggle source
# File lib/cheatly/renderer.rb, line 39
def paragraph(text)
  "#{text}\n"
end