Class: PageTemplate::StackableCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/PageTemplate/commands.rb

Overview

StackableCommand is the parent class of any command that creates a branch in the logic: such as If, Loop, etcetera.

Any child that wants to do more than stand alone must inherit from StackableCommand. We recommend setting @called_as, so all of StackableCommand's ways of closing blocks work.

Direct Known Subclasses

CaseCommand, FilterCommand, IfCommand, LoopCommand

Instance Attribute Summary

Attributes inherited from Command

#called_as

Instance Method Summary collapse

Methods inherited from Command

#output

Constructor Details

#initialize(called_as = nil) ⇒ StackableCommand

allows a number of [% end %], [% end name %], [% endname %] or even [% /name %] to close StackableCommands.

Raises:

  • (ArgumentError)

99
100
101
# File 'lib/PageTemplate/commands.rb', line 99

def initialize(called_as=nil)
  raise ArgumentError, 'StackableCommand should not be called directly'
end

Instance Method Details

#add(block) ⇒ Object

Raises:

  • (ArgumentError)

102
103
104
# File 'lib/PageTemplate/commands.rb', line 102

def add(block)
  raise ArgumentError, 'StackableCommand should not be called directly'
end

#endObject


93
94
# File 'lib/PageTemplate/commands.rb', line 93

def end
end

#to_sObject


105
106
107
# File 'lib/PageTemplate/commands.rb', line 105

def to_s
  "[ #{@called_as} ]"
end