Class: Lisp::Format::Directives::Directive
- 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.
Direct Known Subclasses
ArgJump, BeginCaseConversion, BeginConditional, BeginIteration, Character, CharacterDirective, ClauseSeparator, DollarFP, EndCaseConversion, EndConditional, EndIteration, ExpFP, FFFP, FreshLine, GeneralFP, Indirection, Number, Plural, Print, Radix, SkipWhitespace, Tabulate
Instance Attribute Summary collapse
-
#pos ⇒ Object
readonly
The position at which this directive occurs in the input string.
Instance Method Summary collapse
-
#execute(state) ⇒ Object
This method should be overridden in sub-classes.
-
#initialize(params, modifiers, top, pos) ⇒ Directive
constructor
Given a set of parameters, modifiers, an owning directive if available, and a position in the output string, create a new Directive.
-
#join(other) ⇒ Object
Join this directive with the following one, given in
other
.
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
#pos ⇒ Object (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 |