Sha256: a9f661cbc384e1ae0d0114d38b8eace3e7ccbd63519bed9d22d213c9833030b8
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
# frozen_string_literal: true require_relative "jorycw33_kcl/version" require "base64" require "json" module Jorycw33Kcl extend self class Error < StandardError; end # sig do # type_parameters(:T) # .params(retries: Integer, wait_between_retries: Float, blk: T.proc.returns(T.type_parameter(:T))) # .returns(T.type_parameter(:T)) # end def num_of_times(retries:, wait_between_retries:, &blk) blk.call rescue StandardError => e Kernel.raise e if retries <= 0 Kernel.sleep(wait_between_retries) num_of_times(retries: retries - 1, wait_between_retries: wait_between_retries, &blk) end # sig { params(list: T::Array[T.untyped], blk: T.proc.params(arg: T::Array[T.untyped]).void).void } def with_split(list, &blk) do_with_split(list, false, &blk) end private # sig { params(list: T::Array[T.untyped], is_retry: T::Boolean, blk: T.proc.params(arg: T::Array[T.untyped]).void).void } def do_with_split(list, is_retry, &blk) blk.call(list) rescue StandardError => e Kernel.raise e if is_retry list.each do |item| do_with_split([item], true, &blk) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jorycw33_kcl-0.1.1 | lib/jorycw33_kcl.rb |