Method: HighLine#say

Defined in:
lib/highline.rb

#say(statement) ⇒ Object

The basic output method for HighLine objects. If the provided statement ends with a space or tab character, a newline will not be appended (output will be flush()ed). All other cases are passed straight to Kernel.puts().

The statement argument is processed as an ERb template, supporting embedded Ruby code. The template is evaluated within a HighLine instance’s binding for providing easy access to the ANSI color constants and the HighLine#color() method.

Parameters:



380
381
382
383
384
385
386
387
388
389
390
391
392
# File 'lib/highline.rb', line 380

def say(statement)
  statement = render_and_ident_statement(statement)
  return statement if statement.empty?

  # Don't add a newline if statement ends with whitespace, OR
  # if statement ends with whitespace before a color escape code.
  if /[ \t](\e\[\d+(;\d+)*m)?\Z/ =~ statement
    output.print(statement)
  else
    output.puts(statement)
  end
  output.flush # See: https://github.com/JEG2/highline/pull/276
end