Class List Method List File List

# Class: VertxWebClient::BodyCodec

Inherits:
  Object
  - Object
  - VertxWebClient::BodyCodec
  show all
Defined in:
  /Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/body_codec.rb

## Overview

A codec for encoding and decoding HTTP bodies.

## Class Method Summary (collapse)

- + (::VertxWebClient::BodyCodec) buffer
  The codec.
- + (::VertxWebClient::BodyCodec) create(decode = nil) { ... }
  Create a codec that buffers the entire body and then apply the decode function and returns the result.
- + (::VertxWebClient::BodyCodec) json_object
  The codec.
- + (::VertxWebClient::BodyCodec) none
  A codec that simply discards the response.
- + (::VertxWebClient::BodyCodec) pipe(stream = nil)
  A body codec that pipes the body to a write stream.
- + (::VertxWebClient::BodyCodec) string(encoding = nil)
  A codec for strings using a specific encoding.

## Class Method Details

### + (`::VertxWebClient::BodyCodec`) buffer

Returns the codec

Returns:

- (`::VertxWebClient::BodyCodec`) —
  the codec

Raises:

- (`ArgumentError`)

    31
    32
    33
    34
    35
    36
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/body_codec.rb', line 31

    def self.buffer
      if !block_given?
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebClient::BodyCodec.java_method(:buffer, []).call(),::VertxWebClient::BodyCodec,::Vertx::Buffer.j_api_type)
      end
      raise ArgumentError, "Invalid arguments when calling buffer()"
    end

### + (`::VertxWebClient::BodyCodec`) create(decode = nil) { ... }

Create a codec that buffers the entire body and then apply the `decode` function and returns the result.

Yields:

- the decode function

Returns:

- (`::VertxWebClient::BodyCodec`) —
  the created codec

Raises:

- (`ArgumentError`)

    54
    55
    56
    57
    58
    59
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/body_codec.rb', line 54

    def self.create(decode=nil)
      if block_given? && decode == nil
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebClient::BodyCodec.java_method(:create, [Java::JavaUtilFunction::Function.java_class]).call((Proc.new { |event| ::Vertx::Util::Utils.to_object(yield(::Vertx::Util::Utils.safe_create(event,::Vertx::Buffer))) })),::VertxWebClient::BodyCodec, nil)
      end
      raise ArgumentError, "Invalid arguments when calling create(#{decode})"
    end

### + (`::VertxWebClient::BodyCodec`) json_object

Returns the codec

Returns:

- (`::VertxWebClient::BodyCodec`) —
  the codec

Raises:

- (`ArgumentError`)

    38
    39
    40
    41
    42
    43
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/body_codec.rb', line 38

    def self.json_object
      if !block_given?
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebClient::BodyCodec.java_method(:jsonObject, []).call(),::VertxWebClient::BodyCodec, nil)
      end
      raise ArgumentError, "Invalid arguments when calling json_object()"
    end

### + (`::VertxWebClient::BodyCodec`) none

Returns a codec that simply discards the response

Returns:

- (`::VertxWebClient::BodyCodec`) —
  a codec that simply discards the response

Raises:

- (`ArgumentError`)

    45
    46
    47
    48
    49
    50
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/body_codec.rb', line 45

    def self.none
      if !block_given?
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebClient::BodyCodec.java_method(:none, []).call(),::VertxWebClient::BodyCodec, nil)
      end
      raise ArgumentError, "Invalid arguments when calling none()"
    end

### + (`::VertxWebClient::BodyCodec`) pipe(stream = nil)

A body codec that pipes the body to a write stream.

Parameters:

- stream (`::Vertx::WriteStream`) (defaults to: `nil`) —
  the destination tream

Returns:

- (`::VertxWebClient::BodyCodec`) —
  the body codec for a write stream

Raises:

- (`ArgumentError`)

    63
    64
    65
    66
    67
    68
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/body_codec.rb', line 63

    def self.pipe(stream=nil)
      if stream.class.method_defined?(:j_del) && !block_given?
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebClient::BodyCodec.java_method(:pipe, [Java::IoVertxCoreStreams::WriteStream.java_class]).call(stream.j_del),::VertxWebClient::BodyCodec, nil)
      end
      raise ArgumentError, "Invalid arguments when calling pipe(#{stream})"
    end

### + (`::VertxWebClient::BodyCodec`) string(encoding = nil)

A codec for strings using a specific `encoding`.

Parameters:

- encoding (`String`) (defaults to: `nil`) —
  the encoding

Returns:

- (`::VertxWebClient::BodyCodec`) —
  the codec

Raises:

- (`ArgumentError`)

    22
    23
    24
    25
    26
    27
    28
    29
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/body_codec.rb', line 22

    def self.string(encoding=nil)
      if !block_given? && encoding == nil
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebClient::BodyCodec.java_method(:string, []).call(),::VertxWebClient::BodyCodec, nil)
      elsif encoding.class == String && !block_given?
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebClient::BodyCodec.java_method(:string, [Java::java.lang.String.java_class]).call(encoding),::VertxWebClient::BodyCodec, nil)
      end
      raise ArgumentError, "Invalid arguments when calling string(#{encoding})"
    end