2007-08-16 00:20:18 +04:00
|
|
|
module CodeRay
|
|
|
|
module Encoders
|
|
|
|
|
|
|
|
class Text < Encoder
|
|
|
|
|
|
|
|
include Streamable
|
|
|
|
register_for :text
|
|
|
|
|
|
|
|
FILE_EXTENSION = 'txt'
|
|
|
|
|
|
|
|
DEFAULT_OPTIONS = {
|
|
|
|
:separator => ''
|
|
|
|
}
|
|
|
|
|
|
|
|
protected
|
|
|
|
def setup options
|
2009-11-20 18:50:06 +03:00
|
|
|
@out = ''
|
2007-08-16 00:20:18 +04:00
|
|
|
@sep = options[:separator]
|
|
|
|
end
|
|
|
|
|
2009-11-20 18:50:06 +03:00
|
|
|
def token text, kind
|
|
|
|
@out << text + @sep if text.is_a? ::String
|
2007-08-16 00:20:18 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
def finish options
|
2009-11-20 18:50:06 +03:00
|
|
|
@out.chomp @sep
|
2007-08-16 00:20:18 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|