class Wunderbar::TextBuilder
Public Class Methods
new(scope)
click to toggle source
# File lib/wunderbar/builder.rb, line 411 def initialize(scope) @_target = StringIO.new @_scope = scope end
Public Instance Methods
_(*args)
click to toggle source
# File lib/wunderbar/builder.rb, line 424 def _(*args) @_target.puts(*args) if args.length > 0 self end
_exception(*args)
click to toggle source
Calls superclass method
# File lib/wunderbar/builder.rb, line 442 def _exception(*args) exception = args.first if exception.respond_to? :backtrace Wunderbar.error exception.inspect @_target.puts unless size == 0 @_target.puts exception.inspect exception.backtrace.each do |frame| next if CALLERS_TO_IGNORE.any? {|re| frame =~ re} Wunderbar.warn " #{frame}" @_target.puts " #{frame}" end else super end end
encode(&block)
click to toggle source
# File lib/wunderbar/builder.rb, line 416 def encode(&block) set_variables_from_params before = @_target.string result = self.instance_eval(&block) _ result if before.empty? and result and @_target.string == before @_target.string end
method_missing(method, *args, &block)
click to toggle source
forward to Wunderbar
, @_target, or @_scope
Calls superclass method
# File lib/wunderbar/builder.rb, line 430 def method_missing(method, *args, &block) if Wunderbar.respond_to? method return Wunderbar.send method, *args, &block elsif @_target.respond_to? method return @_target.send method, *args, &block elsif @_scope and @_scope.respond_to? method return @_scope.send method, *args, &block else super end end
system(*args)
click to toggle source
execute a system command, echoing stdin, stdout, and stderr
Calls superclass method
Wunderbar::BuilderClass#system
# File lib/wunderbar/builder.rb, line 459 def system(*args) opts = {} opts = args.pop if Hash === args.last output_prefix = opts[:prefix] || {} output_prefix[:stdin] ||= '$ ' if Hash === args.last # support original code which needed two hashes super do |kind, line| @_target.puts "#{output_prefix[kind]}#{line}" end else super(*args, opts) do |kind, line| @_target.puts "#{output_prefix[kind]}#{line}" end end end
target!()
click to toggle source
# File lib/wunderbar/builder.rb, line 477 def target! @_target.string end