Module: Pry::Warning Private

Defined in:
lib/pry/warning.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Since:

  • v0.13.0

Class Method Summary collapse

Class Method Details

.warn(message) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Prints a warning message with exact file and line location, similar to how Ruby’s -W prints warnings.

Parameters:

  • message (String)

Since:

  • v0.13.0



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/pry/warning.rb', line 12

def self.warn(message)
  if Kernel.respond_to?(:caller_locations)
    location = caller_locations(2..2).first
    path = location.path
    lineno = location.lineno
  else
    # Ruby 1.9.3 support.
    frame = caller[1].split(':') # rubocop:disable Performance/Caller
    path = frame.first
    lineno = frame[1]
  end

  Kernel.warn("#{path}:#{lineno}: warning: #{message}")
end