text.rb
32 lines
| 429 B
| text/x-ruby
|
RubyLexer
|
r638 | module CodeRay | ||
module Encoders | ||||
class Text < Encoder | ||||
include Streamable | ||||
register_for :text | ||||
FILE_EXTENSION = 'txt' | ||||
DEFAULT_OPTIONS = { | ||||
:separator => '' | ||||
} | ||||
protected | ||||
def setup options | ||||
|
r2965 | @out = '' | ||
|
r638 | @sep = options[:separator] | ||
end | ||||
|
r2965 | def token text, kind | ||
@out << text + @sep if text.is_a? ::String | ||||
|
r638 | end | ||
def finish options | ||||
|
r2965 | @out.chomp @sep | ||
|
r638 | end | ||
end | ||||
end | ||||
end | ||||