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.
372 373 374 375 376 377 378 379 380 381 382 383 384 |
# File 'lib/highline.rb', line 372 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) output.flush else output.puts(statement) end end |