Class: Logue::Writer
- Inherits:
-
Object
- Object
- Logue::Writer
- Defined in:
- lib/logue/writer.rb
Instance Attribute Summary collapse
-
#colorize_line ⇒ Object
Returns the value of attribute colorize_line.
-
#colors ⇒ Object
Returns the value of attribute colors.
-
#output ⇒ Object
Returns the value of attribute output.
Instance Method Summary collapse
-
#initialize(output: $stdout, colors: Array.new, colorize_line: false) ⇒ Writer
constructor
A new instance of Writer.
- #line(location, msg, lvl) ⇒ Object
- #print(lstr, lvl) ⇒ Object
Constructor Details
#initialize(output: $stdout, colors: Array.new, colorize_line: false) ⇒ Writer
Returns a new instance of Writer.
10 11 12 13 14 |
# File 'lib/logue/writer.rb', line 10 def initialize output: $stdout, colors: Array.new, colorize_line: false @output = output @colors = colors @colorize_line = colorize_line end |
Instance Attribute Details
#colorize_line ⇒ Object
Returns the value of attribute colorize_line.
8 9 10 |
# File 'lib/logue/writer.rb', line 8 def colorize_line @colorize_line end |
#colors ⇒ Object
Returns the value of attribute colors.
7 8 9 |
# File 'lib/logue/writer.rb', line 7 def colors @colors end |
#output ⇒ Object
Returns the value of attribute output.
6 7 8 |
# File 'lib/logue/writer.rb', line 6 def output @output end |
Instance Method Details
#line(location, msg, lvl) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/logue/writer.rb', line 21 def line location, msg, lvl if lvlcol = @colors[lvl] if @colorize_line line = location + " " + msg line.color lvlcol else location + " " + msg.color(lvlcol) end else location + " " + msg end end |
#print(lstr, lvl) ⇒ Object
16 17 18 19 |
# File 'lib/logue/writer.rb', line 16 def print lstr, lvl str = lvlcol = @colors[lvl] ? lstr.color(lvlcol) : lstr @output.puts str end |