Class Lisp::Format::Directives::BeginConditional
In: lib/facet/lisp-format.rb
Parent: Directive

Represents the ~[ (Begin conditional expression) directive. This is useful to choose among a set of directives depending on arguments and numbers.

Methods

connect   execute   new  

Public Class methods

Set up some variables and basically pass on to super.

Public Instance methods

Connect a set of directives to this conditional directive. A SyntaxError is raised if multiple clauses have been marked as ‘default’, or if too many clauses have been specified for a given set of modifiers.

Process one of the given clauses, depending on the numeric value of the given argument, or a specified parameter. The full form is

  ~n[clause0~;clause1~:;clause2~]

or

  ~:[clause0~;clause1~]

or

  ~@[clause0~]

with the following interpretations

n (nil)
if given, this value will be used to choose a clause instead of reading an arguments value. This is only useful if n is in fact the arguments left parameter (#). An error is raised if this argument does not respond_to? :to_int,
:
instead of choosing a clause by number, the argument is tested as a boolean value, and if false, then first clause is executed, else the second one is,
@
instead of choosing a clause by number, the argument is tested as a boolean value, and if true, the single clause is executed.

[Validate]