to_type

in build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/rbs.rb [5:37]


      def to_type(shape_ref, api)
        _, shape = Api.resolve(shape_ref, api)
        case shape['type']
        when 'blob' then Api.streaming?(shape_ref, api) ? '::IO' : '::String'
        when 'boolean' then 'bool'
        when 'byte' then '::Integer'
        when 'character' then '::String'
        when 'double' then '::Float'
        when 'float' then '::Float'
        when 'integer' then '::Integer'
        when 'list' then "::Array[#{to_type(shape['member'], api)}]"
        when 'long' then '::Integer'
        when 'map' then "::Hash[#{to_type(shape['key'], api)}, #{to_type(shape['value'], api)}]"
        when 'string'
          if shape['enum']
            "(#{shape['enum'].map { |e| "\"#{e}\"" }.join(" | ")})"
          elsif Api.streaming?(shape_ref, api)
            '::IO'
          else
            '::String'
          end
        when 'structure'
          if shape['document']
            'untyped'
          else
            "Types::
          end
        when 'timestamp' then '::Time'
        else
          raise "unhandled type #{shape['type'].inspect}"
        end
      end