Class: GroongaQueryLog::Command::Analyzer::ConsoleReporter::Color
- Inherits:
-
Object
- Object
- GroongaQueryLog::Command::Analyzer::ConsoleReporter::Color
- Defined in:
- lib/groonga-query-log/command/analyzer/reporter/console.rb
Constant Summary collapse
- NAMES =
[ "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", ]
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #+(other) ⇒ Object
- #==(other) ⇒ Object
- #bold? ⇒ Boolean
- #escape_sequence ⇒ Object
- #foreground? ⇒ Boolean
-
#initialize(name, options = {}) ⇒ Color
constructor
A new instance of Color.
- #intensity? ⇒ Boolean
- #italic? ⇒ Boolean
- #sequence ⇒ Object
- #underline? ⇒ Boolean
Constructor Details
#initialize(name, options = {}) ⇒ Color
Returns a new instance of Color.
37 38 39 40 41 42 43 44 45 |
# File 'lib/groonga-query-log/command/analyzer/reporter/console.rb', line 37 def initialize(name, ={}) @name = name @foreground = [:foreground] @foreground = true if @foreground.nil? @intensity = [:intensity] @bold = [:bold] @italic = [:italic] @underline = [:underline] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
36 37 38 |
# File 'lib/groonga-query-log/command/analyzer/reporter/console.rb', line 36 def name @name end |
Instance Method Details
#+(other) ⇒ Object
95 96 97 |
# File 'lib/groonga-query-log/command/analyzer/reporter/console.rb', line 95 def +(other) MixColor.new([self, other]) end |
#==(other) ⇒ Object
67 68 69 70 71 72 73 |
# 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? ⇒ Boolean
55 56 57 |
# File 'lib/groonga-query-log/command/analyzer/reporter/console.rb', line 55 def bold? @bold end |
#escape_sequence ⇒ Object
91 92 93 |
# File 'lib/groonga-query-log/command/analyzer/reporter/console.rb', line 91 def escape_sequence "\e[#{sequence.join(';')}m" end |
#foreground? ⇒ Boolean
47 48 49 |
# File 'lib/groonga-query-log/command/analyzer/reporter/console.rb', line 47 def foreground? @foreground end |
#intensity? ⇒ Boolean
51 52 53 |
# File 'lib/groonga-query-log/command/analyzer/reporter/console.rb', line 51 def intensity? @intensity end |
#italic? ⇒ Boolean
59 60 61 |
# File 'lib/groonga-query-log/command/analyzer/reporter/console.rb', line 59 def italic? @italic end |
#sequence ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# 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? ⇒ Boolean
63 64 65 |
# File 'lib/groonga-query-log/command/analyzer/reporter/console.rb', line 63 def underline? @underline end |