class Temill::Emitters::Printer
Attributes
indent[RW]
output_lines[R]
Public Class Methods
new(io = $stdout, **options)
click to toggle source
# File lib/temill/emitter.rb, line 108 def initialize(io = $stdout, **options) @options = options @output_lines = 0 @indent = '' @io = io end
Public Instance Methods
lineno()
click to toggle source
# File lib/temill/emitter.rb, line 115 def lineno @output_lines + 1 end
obj_to_s(obj)
click to toggle source
# File lib/temill/emitter.rb, line 119 def obj_to_s(obj) case f = @options[:inspect] when Symbol obj.__send__(f) when nil obj.pretty_inspect else f.call(obj) end end
out(str)
click to toggle source
# File lib/temill/emitter.rb, line 153 def out(str) @io.print(str) self end
out_nl(str=nil)
click to toggle source
# File lib/temill/emitter.rb, line 158 def out_nl(str=nil) @io.puts(str) @output_lines += 1 self end
print(obj)
click to toggle source
# File lib/temill/emitter.rb, line 130 def print(obj) print_str(obj_to_s(obj)) end
print_empty_line()
click to toggle source
# File lib/temill/emitter.rb, line 142 def print_empty_line out @indent out_nl '#' end
print_raw(str)
click to toggle source
# File lib/temill/emitter.rb, line 147 def print_raw(str) str.each_line{| line | out_nl line } end
print_str(str)
click to toggle source
# File lib/temill/emitter.rb, line 134 def print_str(str) str.each_line{| line | out @indent out '# ' out_nl line } end