Method: Thor::Shell::Basic#say

Defined in:
lib/thor/shell/basic.rb

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

Say (print) something to the user. If the sentence ends with a whitespace or tab character, a new line is not appended (print + flush). Otherwise are passed straight to puts (behavior got from Highline).

Example

say("I know you knew that.")


98
99
100
101
102
103
104
105
106
# File 'lib/thor/shell/basic.rb', line 98

def say(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
  return if quiet?

  buffer = prepare_message(message, *color)
  buffer << "\n" if force_new_line && !message.to_s.end_with?("\n")

  stdout.print(buffer)
  stdout.flush
end