Module: Syntax
- Defined in:
- lib/syntax.rb,
lib/syntax/common.rb,
lib/syntax/version.rb,
lib/syntax/lang/xml.rb,
lib/syntax/lang/ruby.rb,
lib/syntax/lang/yaml.rb,
lib/syntax/lang/ansic.rb,
lib/syntax/lang/css21.rb,
lib/syntax/lang/sqlite.rb,
lib/syntax/lang/fortran.rb,
lib/syntax/convertors/html.rb,
lib/syntax/lang/javascript.rb,
lib/syntax/convertors/abstract.rb
Defined Under Namespace
Modules: Convertors, Version Classes: AnsiC, CSS21, Default, Fortran, Javascript, Ruby, SQLite, Token, Tokenizer, XML, YAML
Constant Summary collapse
- SYNTAX =
A hash for registering syntax implementations.
Hash.new( Default )
Class Method Summary collapse
-
.all ⇒ Object
Return an array of the names of supported syntaxes.
-
.load(syntax) ⇒ Object
Load the implementation of the requested syntax.
Class Method Details
.all ⇒ Object
Return an array of the names of supported syntaxes.
32 33 34 35 |
# File 'lib/syntax.rb', line 32 def all lang_dir = File.join(File.dirname(__FILE__), "syntax", "lang") Dir["#{lang_dir}/*.rb"].map { |path| File.basename(path, ".rb") } end |
.load(syntax) ⇒ Object
Load the implementation of the requested syntax. If the syntax cannot be found, or if it cannot be loaded for whatever reason, the Default syntax handler will be returned.
22 23 24 25 26 27 28 |
# File 'lib/syntax.rb', line 22 def load( syntax ) begin require "syntax/lang/#{syntax}" rescue LoadError end SYNTAX[ syntax ].new end |