Sha256: 4d695205fb67111c6e2a5d409bdbb0918bcd1c294886412e2bc92067696667c8

Contents?: true

Size: 1.71 KB

Versions: 1225

Compression:

Stored size: 1.71 KB

Contents

require 'stringio'

module Aws
  module Query
    class ParamList

      include Enumerable

      # @api private
      def initialize
        @params = {}
      end

      # @param [String] param_name
      # @param [String, nil] param_value
      # @return [Param]
      def set(param_name, param_value = nil)
        param = Param.new(param_name, param_value)
        @params[param.name] = param
        param
      end
      alias []= set

      # @return [Param, nil]
      def [](param_name)
        @params[param_name.to_s]
      end

      # @param [String] param_name
      # @return [Param, nil]
      def delete(param_name)
        @params.delete(param_name)
      end

      # @return [Enumerable]
      def each(&block)
        to_a.each(&block)
      end

      # @return [Boolean]
      def empty?
        @params.empty?
      end

      # @return [Array<Param>] Returns an array of sorted {Param} objects.
      def to_a
        @params.values.sort
      end

      # @return [String]
      def to_s
        to_a.map(&:to_s).join('&')
      end

      # @return [#read, #rewind, #size]
      def to_io
        IoWrapper.new(self)
      end

      # @api private
      class IoWrapper

        # @param [ParamList] param_list
        def initialize(param_list)
          @param_list = param_list
          @io = StringIO.new(param_list.to_s)
        end

        # @return [ParamList]
        attr_reader :param_list

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

        # @return [void]
        def rewind
          @io.rewind
        end

        # @return [String, nil]
        def read(bytes = nil, output_buffer = nil)
          @io.read(bytes, output_buffer)
        end

      end

    end
  end
end

Version data entries

1,225 entries across 1,225 versions & 2 rubygems

Version Path
aws-sdk-core-2.11.632 lib/aws-sdk-core/query/param_list.rb
aws-sdk-core-2.11.631 lib/aws-sdk-core/query/param_list.rb
aws-sdk-core-2.11.630 lib/aws-sdk-core/query/param_list.rb
aws-sdk-core-2.11.629 lib/aws-sdk-core/query/param_list.rb
aws-sdk-core-2.11.628 lib/aws-sdk-core/query/param_list.rb
aws-sdk-core-2.11.627 lib/aws-sdk-core/query/param_list.rb
aws-sdk-core-2.11.626 lib/aws-sdk-core/query/param_list.rb
aws-sdk-core-2.11.625 lib/aws-sdk-core/query/param_list.rb
aws-sdk-core-2.11.624 lib/aws-sdk-core/query/param_list.rb
aws-sdk-core-2.11.623 lib/aws-sdk-core/query/param_list.rb
aws-sdk-core-2.11.622 lib/aws-sdk-core/query/param_list.rb
aws-sdk-core-2.11.621 lib/aws-sdk-core/query/param_list.rb
aws-sdk-core-2.11.620 lib/aws-sdk-core/query/param_list.rb
aws-sdk-core-2.11.619 lib/aws-sdk-core/query/param_list.rb
aws-sdk-core-2.11.618 lib/aws-sdk-core/query/param_list.rb
aws-sdk-core-2.11.617 lib/aws-sdk-core/query/param_list.rb
aws-sdk-core-2.11.616 lib/aws-sdk-core/query/param_list.rb
aws-sdk-core-2.11.615 lib/aws-sdk-core/query/param_list.rb
aws-sdk-core-2.11.614 lib/aws-sdk-core/query/param_list.rb
aws-sdk-core-2.11.613 lib/aws-sdk-core/query/param_list.rb