Class: Judges::AsciiLoog
Overview
ASCII wrapper for Loog logging facility.
This class wraps any Loog logger and converts Unicode symbols to ASCII equivalents when the –ascii option is enabled.
- Author
-
Yegor Bugayenko ([email protected])
- Copyright
-
Copyright © 2024-2025 Yegor Bugayenko
- License
-
MIT
Constant Summary collapse
- UNICODE_TO_ASCII =
Unicode to ASCII symbol mapping
{ '👍' => '+', '👎' => '-', '❌' => '!', '👉' => '>', '✓' => '+', '✗' => '!', '►' => '>', '◄' => '<', '▼' => 'v', '▲' => '^' }.freeze
Instance Method Summary collapse
-
#debug(message) ⇒ Object
Log a debug message, converting Unicode to ASCII.
-
#error(message) ⇒ Object
Log an error message, converting Unicode to ASCII.
-
#info(message) ⇒ Object
Log an info message, converting Unicode to ASCII.
-
#initialize(loog) ⇒ AsciiLoog
constructor
Initialize the ASCII wrapper.
-
#method_missing(method) ⇒ Object
Delegate all other methods to the original logger.
-
#respond_to_missing?(method, include_private = false) ⇒ Boolean
Check if the original logger responds to a method.
-
#to_ascii(message) ⇒ String
Convert Unicode symbols to ASCII equivalents.
-
#warn(message) ⇒ Object
Log a warning message, converting Unicode to ASCII.
Constructor Details
#initialize(loog) ⇒ AsciiLoog
Initialize the ASCII wrapper.
33 34 35 |
# File 'lib/judges/ascii_loog.rb', line 33 def initialize(loog) @loog = loog end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
Delegate all other methods to the original logger.
73 74 75 |
# File 'lib/judges/ascii_loog.rb', line 73 def method_missing(method, *, &) @loog.send(method, *, &) end |
Instance Method Details
#debug(message) ⇒ Object
Log a debug message, converting Unicode to ASCII.
68 69 70 |
# File 'lib/judges/ascii_loog.rb', line 68 def debug() @loog.debug(to_ascii()) end |
#error(message) ⇒ Object
Log an error message, converting Unicode to ASCII.
62 63 64 |
# File 'lib/judges/ascii_loog.rb', line 62 def error() @loog.error(to_ascii()) end |
#info(message) ⇒ Object
Log an info message, converting Unicode to ASCII.
50 51 52 |
# File 'lib/judges/ascii_loog.rb', line 50 def info() @loog.info(to_ascii()) end |
#respond_to_missing?(method, include_private = false) ⇒ Boolean
Check if the original logger responds to a method.
78 79 80 |
# File 'lib/judges/ascii_loog.rb', line 78 def respond_to_missing?(method, include_private = false) @loog.respond_to?(method, include_private) || super end |
#to_ascii(message) ⇒ String
Convert Unicode symbols to ASCII equivalents.
40 41 42 43 44 45 46 |
# File 'lib/judges/ascii_loog.rb', line 40 def to_ascii() result = .to_s UNICODE_TO_ASCII.each do |unicode, ascii| result = result.gsub(unicode, ascii) end result end |
#warn(message) ⇒ Object
Log a warning message, converting Unicode to ASCII.
56 57 58 |
# File 'lib/judges/ascii_loog.rb', line 56 def warn() @loog.warn(to_ascii()) end |