Class: Lisp::Format::Directives::Directive

Inherits:
Object
  • Object
show all
Defined in:
lib/carat/lisp-format.rb

Overview

Base class for formatting directives. This class makes it easy for sub-classes to access the parameters and modifiers that were given to it when created.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params, modifiers, top, pos) ⇒ Directive

Given a set of parameters, modifiers, an owning directive if available, and a position in the output string, create a new Directive.



523
524
525
# File 'lib/carat/lisp-format.rb', line 523

def initialize(params, modifiers, top, pos)
  @params, @modifiers, @pos = params, modifiers, pos
end

Instance Attribute Details

#posObject (readonly)

The position at which this directive occurs in the input string.



540
541
542
# File 'lib/carat/lisp-format.rb', line 540

def pos
  @pos
end

Instance Method Details

#execute(state) ⇒ Object

This method should be overridden in sub-classes. It gets called when the directive is to be executed. It does nothing by default.



529
# File 'lib/carat/lisp-format.rb', line 529

def execute(state); end

#join(other) ⇒ Object

Join this directive with the following one, given in other. The default is to simply return other. The only known use for this is in SkipWhitespace, where some processing of other is done if it is a Literal.



535
536
537
# File 'lib/carat/lisp-format.rb', line 535

def join(other)
  other
end