Class: Slk::Formatters::MarkdownOutput
- Inherits:
-
Object
- Object
- Slk::Formatters::MarkdownOutput
- Defined in:
- lib/slk/formatters/markdown_output.rb
Overview
Markdown output adapter with same interface as Output Produces markdown formatting instead of ANSI colors
Instance Attribute Summary collapse
-
#quiet ⇒ Object
readonly
Returns the value of attribute quiet.
-
#verbose ⇒ Object
readonly
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#blue(text) ⇒ Object
blue -> ‘text` (code for timestamps).
-
#bold(text) ⇒ Object
Markdown formatting helpers - string interpolation handles nil conversion bold -> text.
-
#cyan(text) ⇒ Object
cyan -> ‘text` (code for metadata like timestamps).
- #debug(message) ⇒ Object
- #error(message) ⇒ Object
-
#gray(text) ⇒ Object
gray -> text (italics for secondary info).
-
#green(text) ⇒ Object
green -> plain text (success doesn’t need markup).
- #info(message) ⇒ Object
-
#initialize(io: $stdout, err: $stderr, color: nil, verbose: false, quiet: false) ⇒ MarkdownOutput
constructor
Accept color: parameter for interface compatibility with Output (ignored for markdown).
-
#magenta(text) ⇒ Object
magenta -> text (italics for secondary).
- #print(message) ⇒ Object
- #puts(message = '') ⇒ Object
-
#red(text) ⇒ Object
red -> text (emphasis for errors).
- #success(message) ⇒ Object
- #warn(message) ⇒ Object
- #with_quiet(value) ⇒ Object
- #with_verbose(value) ⇒ Object
-
#yellow(text) ⇒ Object
yellow -> text (italics for warnings).
Constructor Details
#initialize(io: $stdout, err: $stderr, color: nil, verbose: false, quiet: false) ⇒ MarkdownOutput
Accept color: parameter for interface compatibility with Output (ignored for markdown)
11 12 13 14 15 16 |
# File 'lib/slk/formatters/markdown_output.rb', line 11 def initialize(io: $stdout, err: $stderr, color: nil, verbose: false, quiet: false) # rubocop:disable Lint/UnusedMethodArgument @io = io @err = err @verbose = verbose @quiet = quiet end |
Instance Attribute Details
#quiet ⇒ Object (readonly)
Returns the value of attribute quiet.
8 9 10 |
# File 'lib/slk/formatters/markdown_output.rb', line 8 def quiet @quiet end |
#verbose ⇒ Object (readonly)
Returns the value of attribute verbose.
8 9 10 |
# File 'lib/slk/formatters/markdown_output.rb', line 8 def verbose @verbose end |
Instance Method Details
#blue(text) ⇒ Object
blue -> ‘text` (code for timestamps)
70 71 72 |
# File 'lib/slk/formatters/markdown_output.rb', line 70 def blue(text) "`#{text}`" end |
#bold(text) ⇒ Object
Markdown formatting helpers - string interpolation handles nil conversion bold -> text
50 51 52 |
# File 'lib/slk/formatters/markdown_output.rb', line 50 def bold(text) "**#{text}**" end |
#cyan(text) ⇒ Object
cyan -> ‘text` (code for metadata like timestamps)
80 81 82 |
# File 'lib/slk/formatters/markdown_output.rb', line 80 def cyan(text) "`#{text}`" end |
#debug(message) ⇒ Object
42 43 44 45 46 |
# File 'lib/slk/formatters/markdown_output.rb', line 42 def debug() return unless @verbose @err.puts("*[debug]* #{}") end |
#error(message) ⇒ Object
26 27 28 |
# File 'lib/slk/formatters/markdown_output.rb', line 26 def error() @err.puts("**Error:** #{}") end |
#gray(text) ⇒ Object
gray -> text (italics for secondary info)
85 86 87 |
# File 'lib/slk/formatters/markdown_output.rb', line 85 def gray(text) "*#{text}*" end |
#green(text) ⇒ Object
green -> plain text (success doesn’t need markup)
60 61 62 |
# File 'lib/slk/formatters/markdown_output.rb', line 60 def green(text) text.to_s end |
#info(message) ⇒ Object
38 39 40 |
# File 'lib/slk/formatters/markdown_output.rb', line 38 def info() puts() end |
#magenta(text) ⇒ Object
magenta -> text (italics for secondary)
75 76 77 |
# File 'lib/slk/formatters/markdown_output.rb', line 75 def magenta(text) "*#{text}*" end |
#print(message) ⇒ Object
22 23 24 |
# File 'lib/slk/formatters/markdown_output.rb', line 22 def print() @io.print() unless @quiet end |
#puts(message = '') ⇒ Object
18 19 20 |
# File 'lib/slk/formatters/markdown_output.rb', line 18 def puts( = '') @io.puts() unless @quiet end |
#red(text) ⇒ Object
red -> text (emphasis for errors)
55 56 57 |
# File 'lib/slk/formatters/markdown_output.rb', line 55 def red(text) "**#{text}**" end |
#success(message) ⇒ Object
34 35 36 |
# File 'lib/slk/formatters/markdown_output.rb', line 34 def success() puts("✓ #{}") end |
#warn(message) ⇒ Object
30 31 32 |
# File 'lib/slk/formatters/markdown_output.rb', line 30 def warn() @err.puts("*Warning:* #{}") unless @quiet end |
#with_quiet(value) ⇒ Object
93 94 95 |
# File 'lib/slk/formatters/markdown_output.rb', line 93 def with_quiet(value) self.class.new(io: @io, err: @err, verbose: @verbose, quiet: value) end |
#with_verbose(value) ⇒ Object
89 90 91 |
# File 'lib/slk/formatters/markdown_output.rb', line 89 def with_verbose(value) self.class.new(io: @io, err: @err, verbose: value, quiet: @quiet) end |
#yellow(text) ⇒ Object
yellow -> text (italics for warnings)
65 66 67 |
# File 'lib/slk/formatters/markdown_output.rb', line 65 def yellow(text) "*#{text}*" end |