Module: RDF::Normalize::Utils

Included in:
Carroll2001, URDNA2015, RDF::Normalize::URDNA2015::NormalizationState
Defined in:
lib/rdf/normalize/utils.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.debug(*args) ⇒ Object

Add debug event to debug array, if specified

param [String] message
yieldreturn [String] appended to message, to allow for lazy-evaulation of message


7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rdf/normalize/utils.rb', line 7

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

Instance Method Details

#depth { ... } ⇒ Object

Increase depth around a method invocation

Yields:

  • Yields with no arguments

Yield Returns:

  • (Object)

    returns the result of yielding

Returns:

  • (Object)


26
27
28
29
30
31
# File 'lib/rdf/normalize/utils.rb', line 26

def depth
  @options[:depth] += 1
  ret = yield
  @options[:depth] -= 1
  ret
end