Class: Dry::Monitor::SQL::Colorizers::Rouge
- Inherits:
-
Object
- Object
- Dry::Monitor::SQL::Colorizers::Rouge
- Defined in:
- lib/dry/monitor/sql/colorizers/rouge.rb
Instance Attribute Summary collapse
-
#formatter ⇒ Object
readonly
Returns the value of attribute formatter.
-
#lexer ⇒ Object
readonly
Returns the value of attribute lexer.
Instance Method Summary collapse
- #call(string) ⇒ Object
-
#initialize(theme) ⇒ Rouge
constructor
A new instance of Rouge.
Constructor Details
#initialize(theme) ⇒ Rouge
Returns a new instance of Rouge.
20 21 22 23 |
# File 'lib/dry/monitor/sql/colorizers/rouge.rb', line 20 def initialize(theme) @formatter = ::Rouge::Formatters::Terminal256.new(theme || ::Rouge::Themes::Gruvbox.new) @lexer = ::Rouge::Lexers::SQL.new end |
Instance Attribute Details
#formatter ⇒ Object (readonly)
Returns the value of attribute formatter.
18 19 20 |
# File 'lib/dry/monitor/sql/colorizers/rouge.rb', line 18 def formatter @formatter end |
#lexer ⇒ Object (readonly)
Returns the value of attribute lexer.
18 19 20 |
# File 'lib/dry/monitor/sql/colorizers/rouge.rb', line 18 def lexer @lexer end |
Instance Method Details
#call(string) ⇒ Object
25 26 27 |
# File 'lib/dry/monitor/sql/colorizers/rouge.rb', line 25 def call(string) formatter.format(lexer.lex(string)) end |