Class: PageTemplate::UnknownCommand

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

Overview

An UnknownCommand is exactly that: A command we know nothing about.

We keep this and save it for future use in case we will know something about it before output is called.

Instance Attribute Summary

Attributes inherited from Command

#called_as

Instance Method Summary collapse

Constructor Details

#initialize(command) ⇒ UnknownCommand

Save the command and the parser, so we can look it up and hopefully


75
76
77
# File 'lib/PageTemplate/commands.rb', line 75

def initialize(command)
  @command = command
end

Instance Method Details

#output(namespace) ⇒ Object

If the command that UnknownCommand is set to exists, find out if the command exists in the Parser's glossary.


64
65
66
67
68
69
70
71
72
# File 'lib/PageTemplate/commands.rb', line 64

def output(namespace)
  cls = namespace.parser.glossary.lookup(@command)
  case cls
  when UnknownCommand
    "[ Unknown Command: #{@command} ]"
  else
    cls.output(namespace)
  end
end

#to_sObject


78
79
80
# File 'lib/PageTemplate/commands.rb', line 78

def to_s
  "[ UnknownCommand: #{@command} ]"
end