Class: ApiTommy::Markdown

Inherits:
Object
  • Object
show all
Defined in:
lib/api_tommy/markdown.rb

Class Method Summary collapse

Class Method Details

.code(text, language = nil) ⇒ Object



15
16
17
18
19
# File 'lib/api_tommy/markdown.rb', line 15

def self.code(text, language = nil)
  result = "\n```"
  result << language unless language.nil?
  result << "\n#{text}\n```\n"
end

.p(text) ⇒ Object



11
12
13
# File 'lib/api_tommy/markdown.rb', line 11

def self.p(text)
  "\n#{text.gsub(/[\n]+/, " ")}\n"
end

.th(*headers) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/api_tommy/markdown.rb', line 25

def self.th(*headers)
  "\n".tap do |result|
    headers.each { |header| result << "| #{header} " }
    result << "\n"
    headers.size.times.each { result << "| --- " }
    result << "\n"
  end
end

.title(text, level) ⇒ Object



7
8
9
# File 'lib/api_tommy/markdown.rb', line 7

def self.title(text, level)
  "\n#{"#" * level} #{text}\n"
end

.tr(*values) ⇒ Object



34
35
36
37
38
39
# File 'lib/api_tommy/markdown.rb', line 34

def self.tr(*values)
  "".tap do |result|
    values.each { |value| result << "| #{value} " }
    result << "\n"
  end
end

.ul(text) ⇒ Object



21
22
23
# File 'lib/api_tommy/markdown.rb', line 21

def self.ul(text)
  "* #{text}\n"
end