Module: Kernel

Defined in:
lib/libis/tools/extend/kernel.rb

Instance Method Summary collapse

Instance Method Details

#dputs(value) ⇒ Object



11
12
13
14
# File 'lib/libis/tools/extend/kernel.rb', line 11

def dputs(value)
  name = extract_argstring_from :dputs, caller
  puts "#{name} : '#{value}'"
end

#extract_argstring_from(name, call_stack) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/libis/tools/extend/kernel.rb', line 3

def extract_argstring_from(name, call_stack)
  file, line_number = call_stack.first.match(/^(.+):(\d+)/).captures
  line = File.readlines(file)[line_number.to_i - 1].strip
  argstring = line[/#{name}\s*\(?(.+?)\)?\s*($|#|\[|\})/, 1]
  raise "unable to extract name for #{name} from #{file} line #{line_number}:\n  #{line}" unless argstring
  argstring
end