Class: PageTemplate::Command

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

Overview

Command classes generate text output based on conditions which vary between each class. Command provides an abstract base class to show interface.

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.closerObject (readonly)

Returns the value of attribute closer.



18
19
20
# File 'lib/PageTemplate/commands.rb', line 18

def closer
  @closer
end

.modifierObject (readonly)

Returns the value of attribute modifier.



18
19
20
# File 'lib/PageTemplate/commands.rb', line 18

def modifier
  @modifier
end

Instance Attribute Details

#called_asObject (readonly)

Returns the value of attribute called_as.



16
17
18
# File 'lib/PageTemplate/commands.rb', line 16

def called_as
  @called_as
end

Instance Method Details

#output(namespace = nil) ⇒ Object

Subclasses of Command use the output method to generate their text output. namespace is a Namespace object, which may be required by a particular subclass.

Command#output must return a string

Raises:

  • (NotImplementedError)


26
27
28
29
# File 'lib/PageTemplate/commands.rb', line 26

def output(namespace = nil)
  raise NotImplementedError, 
        "output() must be implemented by subclasses"
end

#to_sObject

to_s of a Command prints out class and command information, for debugging and visual summary of the template without parsing the outputs.



34
35
36
# File 'lib/PageTemplate/commands.rb', line 34

def to_s
  "[ #{self.class} ]"
end