class Campa::Core::Print
Campa function that print “anything” to the $stdout.
Public Instance Methods
call(*stuff, env:)
click to toggle source
It uses {Printer} to transform an Object into a human readable form and sends it to $stdout.
It is possible to override the preference for using $stdout by binding {SYMBOL_OUT} to a desired Object in the env given as a parameter to this method.
@param stuff [Object] anything resulting from evaling a Campa expression @param env [Context] where {SYMBOL_OUT} will be searched
to find an alternative to $stdout
# File lib/campa/core/print.rb, line 16 def call(*stuff, env:) string = stuff .map { |s| s.is_a?(String) ? s : printer.call(s) } .join(" ") (env[SYMBOL_OUT] || $stdout).print(string) nil end
Private Instance Methods
printer()
click to toggle source
# File lib/campa/core/print.rb, line 27 def printer @printer ||= Printer.new end