Class: Lisp::Format::Formatter
Overview
Engine for the format Lexer and Parser. Given an input format string and an initial State, it lets the Parser create the directives and then simply iterates over them, Directive#execute:ing them each.
Instance Method Summary collapse
-
#initialize(format, state) ⇒ Formatter
constructor
Create a Formatter from a String
formatand a Statestate. -
#run ⇒ Object
Parse and run the result.
Constructor Details
#initialize(format, state) ⇒ Formatter
Create a Formatter from a String format and a State state.
413 414 415 |
# File 'lib/carat/lisp-format.rb', line 413 def initialize(format, state) @parser, @state = Parser.new(Lexer.new(format)), state end |
Instance Method Details
#run ⇒ Object
Parse and run the result.
418 419 420 421 |
# File 'lib/carat/lisp-format.rb', line 418 def run Format.execute_directives(@state, @parser.parse) return @state.latest_output.to_s end |