Module: HTTPClient::Util

Module | HTTPClient::Util
In: | lib/httpclient/util.rb

A module for common function.

### Methods

hash_find_value keyword_argument uri_dirname uri_part_of urify

### Public Instance methods

hash_find_value(hash, &block)

Finds a value of a Hash.

keyword_argument(args, *field)

Keyword argument helper.

args: | given arguments.
*field: | a list of arguments to be extracted.

You can extract 3 arguments (a, b, c) with:

      include Util
      def my_method(*args)
        a, b, c = keyword_argument(args, :a, :b, :c)
        ...
      end
      my_method(1, 2, 3)
      my_method(:b => 2, :a = 1)

instead of;

      def my_method(a, b, c)
        ...
      end

uri_dirname(uri)

Returns parent directory URI of the given URI.

uri_part_of(uri, part)

Returns true if the given 2 URIs have a part_of relationship.

- the same scheme
- the same host String (no host resolution or IP-addr conversion)
- the same port number
- target URI‘s path starts with base URI‘s path.

urify(uri)

Gets an URI instance.

[Validate]