Module: Shoes::Highlighter::Syntax
- Defined in:
- lib/shoes/highlighter/common.rb,
lib/shoes/highlighter/lang/ruby.rb
Defined Under Namespace
Classes: Default, Ruby, Token, Tokenizer
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.
185 186 187 188 |
# File 'lib/shoes/highlighter/common.rb', line 185 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.
175 176 177 178 179 180 181 |
# File 'lib/shoes/highlighter/common.rb', line 175 def load(syntax) begin require_relative "lang/#{syntax}" rescue LoadError end SYNTAX[syntax].new end |