Class: Campa::Printer
- Inherits:
-
Object
- Object
- Campa::Printer
- Defined in:
- lib/campa/printer.rb
Overview
Represents a Campa expression in a human readable form.
In general it tries to create a representation that is valid Campa code to make it easy(ier) to copy and paste stuff from the REPL to a file.
Instance Method Summary collapse
-
#call(expr) ⇒ String
Human readable form (almost always valid code) of an Expression.
Instance Method Details
#call(expr) ⇒ String
Returns human readable form (almost always valid code) of an Expression.
21 22 23 24 25 26 |
# File 'lib/campa/printer.rb', line 21 def call(expr) format = FORMATS.fetch(expr.class) do expr.is_a?(Context) ? :context : :default end send(format, expr) end |