Sha256: 5f3f676eda15cb98555a791c812fe00c6b43e7183565201b3afc978427439c62
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
module Luobo class Driver ## implements the factory pattern @@drivers = {} def self.create type c = @@drivers[type.to_sym] raise "No registered driver for type #{type.to_s}" unless c c.new end def self.register_driver type raise "Driver for #{type.to_s} already registed." if @@drivers[type.to_sym] @@drivers[type.to_sym] = self end ## cross-drivers methods and callbacks def convert token pname = "do_" + token.processor_name.downcase if self.respond_to?(pname) self.send(pname.to_sym, token) else self.do__missing(token) end end def exit; end def setup; end def indent token " " * token.indent_level end def do__raw token indent(token) + token.line_code.gsub(/^\s*/, "") + "\n" end def do__missing token src = indent(token) + token.line src += token.block_code + "\n" if token.block_code end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
luobo-0.0.1 | lib/luobo/driver.rb |