Method: Ing::Shell::Basic#say

Defined in:
lib/ing/shell.rb

#say(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)$/)) ⇒ 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.”)



85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/ing/shell.rb', line 85

def say(message="", color=nil, force_new_line=(message.to_s !~ /( |\t)$/))
  message = message.to_s

  message = set_color(message, *color) if color

  spaces = "  " * padding

  if force_new_line
    stdout.puts(spaces + message)
  else
    stdout.print(spaces + message)
  end
  stdout.flush
end