Sha256: 6e2e6c97c8d8b37e7ea17c1fbcb43adf0afac726d1a3fcb12f6c530c179f6b38
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
module RDF::Normalize module Utils # Add debug event to debug array, if specified # # param [String] message # yieldreturn [String] appended to message, to allow for lazy-evaulation of message def debug(*args) options = args.last.is_a?(Hash) ? args.pop : {} return unless options[:debug] || @options[:debug] depth = options[:depth] || @options[:depth] d_str = depth > 100 ? ' ' * 100 + '+' : ' ' * depth list = args list << yield if block_given? message = d_str + (list.empty? ? "" : list.join(": ")) options[:debug] << message if options[:debug].is_a?(Array) @options[:debug] << message if @options[:debug].is_a?(Array) $stderr.puts(message) if @options[:debug] == TrueClass end module_function :debug # Increase depth around a method invocation # @yield # Yields with no arguments # @yieldreturn [Object] returns the result of yielding # @return [Object] def depth @options[:depth] += 1 ret = yield @options[:depth] -= 1 ret end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rdf-normalize-0.1.0 | lib/rdf/normalize/utils.rb |