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
|
2010-03-16 23:29:12 +03:00
|
|
|
super
|
2007-08-16 00:20:18 +04:00
|
|
|
@sep = options[:separator]
|
|
|
|
end
|
|
|
|
|
2010-03-16 23:29:12 +03:00
|
|
|
def text_token text, kind
|
|
|
|
text + @sep
|
2007-08-16 00:20:18 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
def finish options
|
2010-03-16 23:29:12 +03:00
|
|
|
super.chomp @sep
|
2007-08-16 00:20:18 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|