Class: Dry::Monitor::SQL::Colorizers::Rouge

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/monitor/sql/colorizers/rouge.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#formatterObject (readonly)

Returns the value of attribute formatter.



18
19
20
# File 'lib/dry/monitor/sql/colorizers/rouge.rb', line 18

def formatter
  @formatter
end

#lexerObject (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