Module: Kernel

Defined in:
lib/kernel.rb

Instance Method Summary collapse

Instance Method Details

#_betterp(raw, args, options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/kernel.rb', line 14

def _betterp(raw, args, options = {})
  source = Betterp::Source.new(raw, Dir.pwd)
  pretty = options.fetch(:pretty, false)

  Betterp::Output.new(raw, source, pretty: pretty).format(args).each do |str|
    STDOUT.write(str + "\n")
  end

  args.size > 1 ? args : args.first
end

#p(*args) ⇒ Object



4
5
6
7
# File 'lib/kernel.rb', line 4

def p(*args)
  raw = caller(1..1).first
  _betterp(raw, args)
end

#pp(*args) ⇒ Object



9
10
11
12
# File 'lib/kernel.rb', line 9

def pp(*args)
  raw = caller(1..1).first
  _betterp(raw, args, pretty: true)
end