class Fudge::Formatters::Simple
Simple
coloured STDOUT/STDERR formatting
Constants
- CODE
ASCII Color Codes
Attributes
stdout[R]
Public Class Methods
new(stdout=$stdout)
click to toggle source
# File lib/fudge/formatters/simple.rb, line 46 def initialize(stdout=$stdout) @stdout = stdout end
Public Instance Methods
error(message)
click to toggle source
Report Error Message
# File lib/fudge/formatters/simple.rb, line 51 def error(message) ascii :red, message end
info(message)
click to toggle source
Report Information Message
# File lib/fudge/formatters/simple.rb, line 61 def info(message) ascii :cyan, message end
normal(message)
click to toggle source
Normal information
# File lib/fudge/formatters/simple.rb, line 71 def normal(message) message end
notice(message)
click to toggle source
Report Notice Message
# File lib/fudge/formatters/simple.rb, line 66 def notice(message) ascii :yellow, message end
putc(c)
click to toggle source
Output a character
# File lib/fudge/formatters/simple.rb, line 88 def putc(c) stdout.putc(c) end
puts(message)
click to toggle source
Directly output
# File lib/fudge/formatters/simple.rb, line 76 def puts(message) stdout.puts message end
success(message)
click to toggle source
Report Success Message
# File lib/fudge/formatters/simple.rb, line 56 def success(message) ascii :bright, :green, message end
write() { |w| ... }
click to toggle source
Yields a writer which can chain message types to output
# File lib/fudge/formatters/simple.rb, line 81 def write w = Writer.new(self) yield w w.write(stdout) end
Private Instance Methods
ascii(*args)
click to toggle source
# File lib/fudge/formatters/simple.rb, line 94 def ascii(*args) txt = args.pop codes = args.map { |a| coded(a) } codes << txt << coded(:off) codes.join '' end
coded(code)
click to toggle source
# File lib/fudge/formatters/simple.rb, line 101 def coded(code) "\e[#{CODE[code]}m" end