Class: Alphavantage::Crypto

Inherits:
Object
  • Object
show all
Includes:
HelperFunctions
Defined in:
lib/Crypto.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HelperFunctions

#check_argument, #check_datatype, #method_missing, #open_struct, #recreate_metadata_key, #return_client, #return_int_val, #return_matype, #return_series, #return_value, #which_series

Constructor Details

#initialize(symbol:, datatype: "json", key:, verbose: false, market:) ⇒ Crypto

Returns a new instance of Crypto.



5
6
7
8
9
10
11
# File 'lib/Crypto.rb', line 5

def initialize symbol:, datatype: "json", key:, verbose: false, market:
  check_argument([true, false], verbose, "verbose")
  @client = return_client(key, verbose)
  @symbol = symbol
  @market = market
  @datatype = datatype
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class HelperFunctions

Instance Attribute Details

#datatypeObject

Returns the value of attribute datatype.



14
15
16
# File 'lib/Crypto.rb', line 14

def datatype
  @datatype
end

#marketObject

Returns the value of attribute market.



13
14
15
# File 'lib/Crypto.rb', line 13

def market
  @market
end

#symbolObject

Returns the value of attribute symbol.



13
14
15
# File 'lib/Crypto.rb', line 13

def symbol
  @symbol
end

Instance Method Details

#timeseries(type: "intraday", market: @market, file: nil, datatype: @datatype) ⇒ Object



21
22
23
24
# File 'lib/Crypto.rb', line 21

def timeseries type: "intraday", market: @market, file: nil, datatype: @datatype
  Alphavantage::Crypto_Timeseries.new type: type, market: market,
    symbol: @symbol, datatype: datatype, file: file, key: @client
end