Class: Parklife::Logger
- Inherits:
-
Object
- Object
- Parklife::Logger
- Extended by:
- Forwardable
- Defined in:
- lib/parklife/logger.rb
Instance Attribute Summary collapse
-
#no_colour ⇒ Object
Returns the value of attribute no_colour.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
- #colour(string, *colours) ⇒ Object
-
#initialize(stdout = $stdout, stderr = $stderr, no_colour: false) ⇒ Logger
constructor
A new instance of Logger.
- #warn(*message) ⇒ Object
Constructor Details
#initialize(stdout = $stdout, stderr = $stderr, no_colour: false) ⇒ Logger
Returns a new instance of Logger.
12 13 14 15 16 17 |
# File 'lib/parklife/logger.rb', line 12 def initialize(stdout = $stdout, stderr = $stderr, no_colour: false) @stdout = stdout @stderr = stderr @no_colour = no_colour @thor_color = Thor::Shell::Color.new end |
Instance Attribute Details
#no_colour ⇒ Object
Returns the value of attribute no_colour.
9 10 11 |
# File 'lib/parklife/logger.rb', line 9 def no_colour @no_colour end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
10 11 12 |
# File 'lib/parklife/logger.rb', line 10 def stderr @stderr end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
10 11 12 |
# File 'lib/parklife/logger.rb', line 10 def stdout @stdout end |
Instance Method Details
#colour(string, *colours) ⇒ Object
21 22 23 |
# File 'lib/parklife/logger.rb', line 21 def colour(string, *colours) no_colour ? string : @thor_color.set_color(string, *colours) end |
#warn(*message) ⇒ Object
25 26 27 |
# File 'lib/parklife/logger.rb', line 25 def warn(*) stderr.puts(colour(*, :on_red)) end |