Class: LicenseFinder::Printer

Inherits:
Object
  • Object
show all
Defined in:
lib/license_finder/printer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePrinter

:nodoc:



7
8
9
10
11
12
# File 'lib/license_finder/printer.rb', line 7

def initialize # :nodoc:
  @base = nil
  @mute = false
  @padding = 0
  @always_force = false
end

Instance Attribute Details

#paddingObject

Returns the value of attribute padding.



5
6
7
# File 'lib/license_finder/printer.rb', line 5

def padding
  @padding
end

Instance Method Details

#prepare_message(message, *color) ⇒ Object



22
23
24
25
# File 'lib/license_finder/printer.rb', line 22

def prepare_message(message, *color)
  spaces = '  ' * padding
  spaces + set_color(message.to_s, *color)
end

#say(message = '', color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/)) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/license_finder/printer.rb', line 14

def say(message = '', color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
  buffer = prepare_message(message, *color)
  buffer << "\n" if force_new_line && !message.to_s.end_with?("\n")

  stdout.print(buffer)
  stdout.flush
end

#set_color(string) ⇒ Object

:nodoc:



27
28
29
# File 'lib/license_finder/printer.rb', line 27

def set_color(string, *) # :nodoc:
  string
end

#stdoutObject



35
36
37
# File 'lib/license_finder/printer.rb', line 35

def stdout
  $stdout
end