diff options
author | Nobuyoshi Nakada <[email protected]> | 2019-12-10 20:22:42 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2019-12-13 20:47:07 +0900 |
commit | 0b5268afbcf11c299e11102c366e836ae55cc39f (patch) | |
tree | 74613a39472c9a02b4f606f30a740ad095488f11 /warning.rb | |
parent | 82cc2843a92b286cc13afd0860a4e111d4ea2a0b (diff) |
Moved Kernel#warn to warning.rb
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2739
Diffstat (limited to 'warning.rb')
-rw-r--r-- | warning.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/warning.rb b/warning.rb new file mode 100644 index 0000000000..8361176491 --- /dev/null +++ b/warning.rb @@ -0,0 +1,44 @@ +# encoding: utf-8 +# fronzen-string-literal: true + +module Kernel + + # call-seq: + # warn(*msgs, uplevel: nil) -> nil + # + # If warnings have been disabled (for example with the + # <code>-W0</code> flag), does nothing. Otherwise, + # converts each of the messages to strings, appends a newline + # character to the string if the string does not end in a newline, + # and calls Warning.warn with the string. + # + # warn("warning 1", "warning 2") + # + # <em>produces:</em> + # + # warning 1 + # warning 2 + # + # If the <code>uplevel</code> keyword argument is given, the string will + # be prepended with information for the given caller frame in + # the same format used by the <code>rb_warn</code> C function. + # + # # In baz.rb + # def foo + # warn("invalid call to foo", uplevel: 1) + # end + # + # def bar + # foo + # end + # + # bar + # + # <em>produces:</em> + # + # baz.rb:6: warning: invalid call to foo + # + def warn(*msgs, uplevel: nil) + __builtin_rb_warn_m(msgs, uplevel) + end +end |