Class: Codex::TemplateHandler

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/codex/template_handler.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTemplateHandler

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

#handlersObject (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