Class: Codex::TemplateHandler
- Inherits:
-
Object
- Object
- Codex::TemplateHandler
- Includes:
- Singleton
- Defined in:
- lib/codex/template_handler.rb
Instance Attribute Summary collapse
-
#handlers ⇒ Object
readonly
Returns the value of attribute handlers.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ TemplateHandler
constructor
A new instance of TemplateHandler.
Constructor Details
#initialize ⇒ TemplateHandler
Returns a new instance of TemplateHandler.
7 8 9 10 |
# File 'lib/codex/template_handler.rb', line 7 def initialize # just return the content for unknown formats @handlers = Hash.new(lambda {|c| c }) end |
Instance Attribute Details
#handlers ⇒ Object (readonly)
Returns the value of attribute handlers.
5 6 7 |
# File 'lib/codex/template_handler.rb', line 5 def handlers @handlers end |
Class Method Details
.choose(file) ⇒ Object
16 17 18 |
# File 'lib/codex/template_handler.rb', line 16 def self.choose(file) instance.handlers[File.extname(file.to_s).sub(/^\./, '')] end |
.register(extension, &klass) ⇒ Object
12 13 14 |
# File 'lib/codex/template_handler.rb', line 12 def self.register(extension, &klass) instance.handlers[extension.to_s] = klass end |