Class: Logue::BaseWriter
- Inherits:
-
Object
- Object
- Logue::BaseWriter
- Defined in:
- lib/logue/core/base_writer.rb
Direct Known Subclasses
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) ⇒ BaseWriter
constructor
A new instance of BaseWriter.
- #print(lstr, lvl) ⇒ Object
- #write(location, str, level) ⇒ Object
Constructor Details
#initialize(output: $stdout, colors: Array.new, colorize_line: false) ⇒ BaseWriter
Returns a new instance of BaseWriter.
7 8 9 10 11 |
# File 'lib/logue/core/base_writer.rb', line 7 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.
5 6 7 |
# File 'lib/logue/core/base_writer.rb', line 5 def colorize_line @colorize_line end |
#colors ⇒ Object
Returns the value of attribute colors.
4 5 6 |
# File 'lib/logue/core/base_writer.rb', line 4 def colors @colors end |
#output ⇒ Object
Returns the value of attribute output.
3 4 5 |
# File 'lib/logue/core/base_writer.rb', line 3 def output @output end |
Instance Method Details
#print(lstr, lvl) ⇒ Object
13 14 15 16 |
# File 'lib/logue/core/base_writer.rb', line 13 def print lstr, lvl str = @colors[lvl] ? lstr.color(lvl) : lstr @output.puts str end |
#write(location, str, level) ⇒ Object
18 19 20 21 |
# File 'lib/logue/core/base_writer.rb', line 18 def write location, str, level lstr = location + " " + str print lstr, level end |