Write Data

Methods
#
E
I
N
R
S
W
Attributes
[RW] kwdonly
[RW] output
[RW] stack
[RW] stdout
[RW] top
Class Public methods
new(out)
# File tool/enc-unicode.rb, line 283
def initialize(out)
  @top = @output = []
  @stack = []
  $stdout, @stdout = self, out
end
Instance Public methods
<<(str)
Alias for: write
_show(dest, ary, syms)
# File tool/enc-unicode.rb, line 314
def _show(dest, ary, syms)
  if Symbol === (sym = ary[0])
    unless syms.include?(sym)
      return
    end
  end
  ary.each do |e|
    case e
    when Array
      _show(dest, e, syms)
    when String
      dest.print e
    end
  end
end
endif(sym)
# File tool/enc-unicode.rb, line 300
def endif(sym)
  if @kwdonly
    @stdout.puts "#endif /* #{sym} */"
    return
  end
  unless sym == @top[0]
    restore
    raise ArgumentError, "#{sym} unmatch to #{@top[0]}"
  end
  @top = @stack.pop
end
ifdef(sym)
# File tool/enc-unicode.rb, line 291
def ifdef(sym)
  if @kwdonly
    @stdout.puts "#ifdef #{sym}"
    return
  end
  @stack << @top
  @top << tmp = [sym]
  @top = tmp
end
restore()
# File tool/enc-unicode.rb, line 288
def restore
  $stdout = @stdout
end
show(dest, *syms)
# File tool/enc-unicode.rb, line 311
def show(dest, *syms)
  _show(dest, @output, syms)
end
write(str)
Also aliased as: <<
# File tool/enc-unicode.rb, line 329
def write(str)
  if @kwdonly
    @stdout.write(str)
  else
    @top << str
  end
  self
end