Module: TwelvedataRuby

Defined in:
lib/twelvedata_ruby.rb,
lib/twelvedata_ruby/error.rb,
lib/twelvedata_ruby/utils.rb,
lib/twelvedata_ruby/client.rb,
lib/twelvedata_ruby/request.rb,
lib/twelvedata_ruby/endpoint.rb,
lib/twelvedata_ruby/response.rb

Overview

The one module that all the classes and modules of this gem are namespaced

Defined Under Namespace

Modules: Utils Classes: BadRequestResponseError, Client, Endpoint, EndpointError, EndpointNameError, EndpointParametersKeysError, EndpointRequiredParametersError, Error, ForbiddenResponseError, InternalServerResponseErro, NotFoundResponseError, PageNotFoundResponseError, ParameterTooLongResponseError, Request, Response, ResponseError, TooManyRequestsResponseError, UnauthorizedResponseError

Constant Summary collapse

VERSION =

Holds the current version

Returns:

  • (String)

    version number

"0.3.0"

Class Method Summary collapse

Class Method Details

.client(**options) ⇒ Client

A convenient and clearer way of getting and overriding default attribute values of the singleton ‘Client.instance`

Parameters:

  • options (Hash)

    the optional Hash object that may contain values to override the cd Docdefaults

Options Hash (**options):

  • :apikey (Symbol, String)

    the private key from Twelvedata API key

  • :connect_timeout (Integer, String)

    milliseconds

    @example Passing a nil options

    TwelvedataRuby.client
    

    The singleton instance object returned will use the default values for its attributes

    @example Passing values of ‘:apikey` and `:connect_timeout`

    TwelvedataRuby.client(apikey: "my-twelvedata-apikey", connect_timeout: 3000)
    

    @example or, chain with other Client instance method

    TwelvedataRuby.client(apikey: "my-twelvedata-apikey", connect_timeout: 3000).quote(symbol: "IBM")
    

    In the last example, calling ‘#quote`, a valid API endpoint, an instance method with the same name was dynamically defined and then fired up an API request to Twelvedata.

Returns:

  • (Client)

    singleton instance



38
39
40
41
42
# File 'lib/twelvedata_ruby.rb', line 38

def self.client(**options)
  client = Client.instance
  client.options = (client.options || {}).merge(options)
  client
end