Class: RubyJard::Decorators::LocDecorator
- Inherits:
-
Object
- Object
- RubyJard::Decorators::LocDecorator
- Defined in:
- lib/ruby_jard/decorators/loc_decorator.rb
Overview
Decorate a line of code fetched from the source file. The line is tokenized, and feed into JardEncoder to append color (with Span).
Defined Under Namespace
Classes: JardLocEncoder
Instance Method Summary collapse
- #decorate(loc, file = nil) ⇒ Object
-
#initialize ⇒ LocDecorator
constructor
A new instance of LocDecorator.
Constructor Details
#initialize ⇒ LocDecorator
Returns a new instance of LocDecorator.
12 13 14 |
# File 'lib/ruby_jard/decorators/loc_decorator.rb', line 12 def initialize @encoder = JardLocEncoder.new end |
Instance Method Details
#decorate(loc, file = nil) ⇒ Object
16 17 18 19 20 |
# File 'lib/ruby_jard/decorators/loc_decorator.rb', line 16 def decorate(loc, file = nil) tokens = CodeRay.scan(loc, extension(file)) spans = @encoder.encode_tokens(tokens) [spans, tokens] end |