Skip to content

Commit

Permalink
use self? to express singleton and instance method
Browse files Browse the repository at this point in the history
  • Loading branch information
m11o committed Feb 9, 2021
1 parent d724155 commit 5ff07e8
Showing 1 changed file with 1 addition and 32 deletions.
33 changes: 1 addition & 32 deletions stdlib/timeout/0/timeout.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -51,38 +51,7 @@ module Timeout
# Timeout` into your classes so they have a #timeout method, as well as a module
# method, so you can call it directly as Timeout.timeout().
#
def self.timeout: (Numeric? sec, ?singleton(Exception) klass, ?String message) { (Numeric sec) -> untyped } -> untyped

private

# Perform an operation in a block, raising an error if it takes longer than
# `sec` seconds to complete.
#
# `sec`
# : Number of seconds to wait for the block to terminate. Any number may be
# used, including Floats to specify fractional seconds. A value of 0 or
# `nil` will execute the block without any timeout.
# `klass`
# : Exception Class to raise if the block fails to terminate in `sec` seconds.
# Omitting will use the default, Timeout::Error
# `message`
# : Error message to raise with Exception Class. Omitting will use the
# default, "execution expired"
#
#
# Returns the result of the block **if** the block completed before `sec`
# seconds, otherwise throws an exception, based on the value of `klass`.
#
# The exception thrown to terminate the given block cannot be rescued inside the
# block unless `klass` is given explicitly. However, the block can use ensure to
# prevent the handling of the exception. For that reason, this method cannot be
# relied on to enforce timeouts for untrusted blocks.
#
# Note that this is both a method of module Timeout, so you can `include
# Timeout` into your classes so they have a #timeout method, as well as a module
# method, so you can call it directly as Timeout.timeout().
#
def timeout: (Numeric? sec, ?singleton(Exception) klass, ?String message) { (Numeric sec) -> untyped } -> untyped
def self?.timeout: (Numeric? sec, ?singleton(Exception) klass, ?String message) { (Numeric sec) -> untyped } -> untyped
end

Timeout::VERSION: String

0 comments on commit 5ff07e8

Please sign in to comment.