Sha256: 19390556cfcff4e931ffc376ff28e756dd8fa9595b4baa7af9a2a02fe3ca278d

Contents?: true

Size: 799 Bytes

Versions: 11

Compression:

Stored size: 799 Bytes

Contents

# frozen_string_literal: true

module HTTP
  module FormData
    # Common behaviour for objects defined by an IO object.
    module Readable
      # Returns IO content.
      #
      # @return [String]
      def to_s
        rewind
        content = read
        rewind
        content
      end

      # Reads and returns part of IO content.
      #
      # @param [Integer] length Number of bytes to retrieve
      # @param [String] outbuf String to be replaced with retrieved data
      #
      # @return [String, nil]
      def read(length = nil, outbuf = nil)
        @io.read(length, outbuf)
      end

      # Returns IO size.
      #
      # @return [Integer]
      def size
        @io.size
      end

      # Rewinds the IO.
      def rewind
        @io.rewind
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
direct7-0.0.18 vendor/bundle/ruby/2.7.0/gems/http-form_data-2.3.0/lib/http/form_data/readable.rb
direct7-0.0.17 vendor/bundle/ruby/2.7.0/gems/http-form_data-2.3.0/lib/http/form_data/readable.rb
direct7-0.0.16 vendor/bundle/ruby/2.7.0/gems/http-form_data-2.3.0/lib/http/form_data/readable.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/http-form_data-2.3.0/lib/http/form_data/readable.rb
direct7-0.0.13 vendor/bundle/ruby/2.7.0/gems/http-form_data-2.3.0/lib/http/form_data/readable.rb
direct7-0.0.12 vendor/bundle/ruby/2.7.0/gems/http-form_data-2.3.0/lib/http/form_data/readable.rb
direct7-0.0.11 vendor/bundle/ruby/2.7.0/gems/http-form_data-2.3.0/lib/http/form_data/readable.rb
http-form_data-2.3.0 lib/http/form_data/readable.rb
http-form_data-2.2.0 lib/http/form_data/readable.rb
http-form_data-2.1.1 lib/http/form_data/readable.rb
http-form_data-2.1.0 lib/http/form_data/readable.rb