Class: Campa::Core::Print

Inherits:
Object
  • Object
show all
Defined in:
lib/campa/core/print.rb

Overview

Campa function that print “anything” to the $stdout.

Instance Method Summary collapse

Instance Method Details

#call(*stuff, env:) ⇒ Object

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.

Parameters:

  • stuff (Object)

    anything resulting from evaling a Campa expression

  • env (Context)

    where SYMBOL_OUT will be searched to find an alternative to $stdout



16
17
18
19
20
21
22
23
# 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