class Campa::Core::PrintLn
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.
Uses #puts method in the output to add a new line after sending each String representation created via {Printer} be sent to the output.
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_ln.rb, line 20 def call(*stuff, env:) out = env[SYMBOL_OUT] || $stdout stuff.each { |s| out.puts(s.is_a?(String) ? s : printer.call(s)) } nil end
Private Instance Methods
printer()
click to toggle source
# File lib/campa/core/print_ln.rb, line 28 def printer @printer ||= Printer.new end