Class: Lisp::Format::Directives::BeginCaseConversion

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

Overview

Represents the ~( (Begin case-conversion) directive. Everything contained within it and its matching pair ~) (End case-conversion) directive is subject to case conversion, such as upcasing or capitalization.

Instance Attribute Summary

Attributes inherited from Directive

#pos

Instance Method Summary collapse

Methods inherited from Directive

#initialize, #join

Constructor Details

This class inherits a constructor from Lisp::Format::Directives::Directive

Instance Method Details

#execute(state) ⇒ Object

Outputs the contained output case converted using some method that depends on the combination of modifiers given to this directive. The full form is

~:@(

with the following interpretations

no modifiers

output is downcased,

:

every word is capitalized in the output,

@

the first word is capitalized in the output,

:@

output is upcased.



1450
1451
1452
1453
1454
1455
1456
1457
# File 'lib/carat/lisp-format.rb', line 1450

def execute(state)
  conv = :DOWN
  conv = :CAP if colon_mod?
  conv = :CAP_FIRST if at_mod?
  conv = :UP if colon_mod? and at_mod?
  state.case_conv = conv
  state.push_output
end