Method: CodeRay.encoder
- Defined in:
- lib/coderay.rb
.encoder(format, options = {}) ⇒ Object
Finds the Encoder class for format and creates an instance, passing options to it.
Example:
require 'coderay'
stats = CodeRay.encoder(:statistic)
stats.encode("puts 17 + 4\n", :ruby)
puts '%d out of %d tokens have the kind :integer.' % [
stats.type_stats[:integer].count,
stats.real_token_count
]
#-> 2 out of 4 tokens have the kind :integer.
270 271 272 |
# File 'lib/coderay.rb', line 270 def encoder format, = {} Encoders[format].new end |