class Lingo::Attendee::TextWriter
Public Instance Methods
control(cmd, param = nil, *)
click to toggle source
# File lib/lingo/attendee/text_writer.rb, line 96 def control(cmd, param = nil, *) case cmd when :LIR @lir = true unless @lir.nil? when :FILE @no_sep, @io = true, (@stdout = stdout?(@ext)) ? open_stdout : open_path(get_path(param, @ext), 'w') @lir_rec_no, @lir_rec_buf = '', [] when :RECORD if @lir @no_sep = true flush_lir_buffer @lir_rec_no = param end when :EOL @no_sep = true @io.puts unless @lir || @no_puts when :EOF flush_lir_buffer if @lir @io.close unless @stdout end end
init()
click to toggle source
# File lib/lingo/attendee/text_writer.rb, line 83 def init @encoding = get_enc @ext = get_key('ext', 'txt2') @lir = get_key('lir-format', false) @sep = get_key('sep', nil) unless @lir @sep &&= @sep.evaluate @sep ||= ' ' @no_sep, @no_puts = true, false end
process(obj)
click to toggle source
# File lib/lingo/attendee/text_writer.rb, line 121 def process(obj) obj = obj.form if obj.is_a?(WordForm) @lir ? @lir_rec_buf << obj : begin @no_sep ? @no_sep = false : @io.print(@sep) @io.print(obj) end end
Private Instance Methods
flush_lir_buffer()
click to toggle source
# File lib/lingo/attendee/text_writer.rb, line 132 def flush_lir_buffer unless @lir_rec_no.empty? || @lir_rec_buf.empty? buf = [@lir_rec_no, @lir_rec_buf.join(@sep), "\n"] @sep =~ /\n/ ? buf.insert(1, "\n").unshift('*') : buf.insert(1, '*') @io.print(*buf) end @lir_rec_no = '' @lir_rec_buf.clear end