Class: Parklife::Logger

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/parklife/logger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_colourObject

Returns the value of attribute no_colour.



9
10
11
# File 'lib/parklife/logger.rb', line 9

def no_colour
  @no_colour
end

#stderrObject (readonly)

Returns the value of attribute stderr.



10
11
12
# File 'lib/parklife/logger.rb', line 10

def stderr
  @stderr
end

#stdoutObject (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(*message)
  stderr.puts(colour(*message, :on_red))
end