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