class GroongaQueryLog::Command::Analyzer::ConsoleReporter::Color

Constants

NAMES

Attributes

name[R]

Public Class Methods

new(name, options={}) click to toggle source
# File lib/groonga-query-log/command/analyzer/reporter/console.rb, line 37
def initialize(name, options={})
  @name = name
  @foreground = options[:foreground]
  @foreground = true if @foreground.nil?
  @intensity = options[:intensity]
  @bold = options[:bold]
  @italic = options[:italic]
  @underline = options[:underline]
end

Public Instance Methods

+(other) click to toggle source
# File lib/groonga-query-log/command/analyzer/reporter/console.rb, line 95
def +(other)
  MixColor.new([self, other])
end
==(other) click to toggle source
# File lib/groonga-query-log/command/analyzer/reporter/console.rb, line 67
def ==(other)
  self.class === other and
    [name, foreground?, intensity?,
     bold?, italic?, underline?] ==
    [other.name, other.foreground?, other.intensity?,
     other.bold?, other.italic?, other.underline?]
end
bold?() click to toggle source
# File lib/groonga-query-log/command/analyzer/reporter/console.rb, line 55
def bold?
  @bold
end
escape_sequence() click to toggle source
# File lib/groonga-query-log/command/analyzer/reporter/console.rb, line 91
def escape_sequence
  "\e[#{sequence.join(';')}m"
end
foreground?() click to toggle source
# File lib/groonga-query-log/command/analyzer/reporter/console.rb, line 47
def foreground?
  @foreground
end
intensity?() click to toggle source
# File lib/groonga-query-log/command/analyzer/reporter/console.rb, line 51
def intensity?
  @intensity
end
italic?() click to toggle source
# File lib/groonga-query-log/command/analyzer/reporter/console.rb, line 59
def italic?
  @italic
end
sequence() click to toggle source
# File lib/groonga-query-log/command/analyzer/reporter/console.rb, line 75
def sequence
  sequence = []
  if @name == "none"
  elsif @name == "reset"
    sequence << "0"
  else
    foreground_parameter = foreground? ? 3 : 4
    foreground_parameter += 6 if intensity?
    sequence << "#{foreground_parameter}#{NAMES.index(@name)}"
  end
  sequence << "1" if bold?
  sequence << "3" if italic?
  sequence << "4" if underline?
  sequence
end
underline?() click to toggle source
# File lib/groonga-query-log/command/analyzer/reporter/console.rb, line 63
def underline?
  @underline
end