lib/read_limiter.rb
# Returns at most `n_bytes` of data from the IO or less if less data was available
# before the EOF was hit
#
# @param n_bytes[Integer]
# @return [String, nil] the content read from the IO or `nil` if no data was available
Returns at most `n_bytes` of data from the IO or less if less data was available
before the EOF was hit
Returns at most ` n_bytes ` of data from the IO or less if less data was available before the EOF was hit
def read(n_bytes)
    @bytes += n_bytes
    @reads += 1
    if @max_bytes && @bytes > @max_bytes
      raise BudgetExceeded, 'Read bytes budget (%d) exceeded' % @max_bytes
    end
    if @max_reads && @reads > @max_reads
      raise BudgetExceeded, 'Number of read() calls exceeded (%d max)' % @max_reads
    end
    @io.read(n_bytes)
  end
def read ( n_bytes ) @bytes += n_bytes @reads += 1 if @max_bytes && @bytes > @max_bytes raise BudgetExceeded , 'Read bytes budget (%d) exceeded' % @max_bytes end if @max_reads && @reads > @max_reads raise BudgetExceeded , 'Number of read() calls exceeded (%d max)' % @max_reads end @io . read ( n_bytes ) end
Returns at most `n_bytes` of data from the IO or less if less data was available
before the EOF was hit
Returns at most ` n_bytes ` of data from the IO or less if less data was available before the EOF was hit
the content read from the IO or `nil` if no data was available
the content read from the IO or ` nil ` if no data was available
String, nil
n_bytes
None