Replace Kernel.#open with URI.open in doc

Because `Kernel.#open` no longer opens URI since Ruby 3.0.
This commit is contained in:
Masataka Pocke Kuwabara 2021-01-08 23:52:35 +09:00 committed by Jeremy Evans
parent 98bd7e87a0
commit 391ee3ee3a
Notes: git 2021-01-09 00:32:02 +09:00
2 changed files with 4 additions and 4 deletions

View File

@ -1711,13 +1711,13 @@ lazy_generator_init(VALUE enumerator, VALUE procs)
* *
* # This will fetch all URLs before selecting * # This will fetch all URLs before selecting
* # necessary data * # necessary data
* URLS.map { |u| JSON.parse(open(u).read) } * URLS.map { |u| JSON.parse(URI.open(u).read) }
* .select { |data| data.key?('stats') } * .select { |data| data.key?('stats') }
* .first(5) * .first(5)
* *
* # This will fetch URLs one-by-one, only till * # This will fetch URLs one-by-one, only till
* # there is enough data to satisfy the condition * # there is enough data to satisfy the condition
* URLS.lazy.map { |u| JSON.parse(open(u).read) } * URLS.lazy.map { |u| JSON.parse(URI.open(u).read) }
* .select { |data| data.key?('stats') } * .select { |data| data.key?('stats') }
* .first(5) * .first(5)
* *

View File

@ -105,7 +105,7 @@ module Kernel
# require 'json' # require 'json'
# #
# construct_url(arguments). # construct_url(arguments).
# then {|url| open(url).read }. # then {|url| URI.open(url).read }.
# then {|response| JSON.parse(response) } # then {|response| JSON.parse(response) }
# #
# When called without block, the method returns +Enumerator+, # When called without block, the method returns +Enumerator+,
@ -138,7 +138,7 @@ module Kernel
# require 'json' # require 'json'
# #
# construct_url(arguments). # construct_url(arguments).
# then {|url| open(url).read }. # then {|url| URI.open(url).read }.
# then {|response| JSON.parse(response) } # then {|response| JSON.parse(response) }
# #
def yield_self def yield_self