Class: Ctfc

Inherits:
CTFC::Data show all
Defined in:
lib/ctfc.rb

Overview

Note:

For instance methods look at CTFC::Data.

For easier job use Ctfc, instead of typing CTFC::Data. You can define default coins with Ctfc::COINS=

Direct Known Subclasses

Crypto

Constant Summary

Constants included from CTFC::CONFIG

CTFC::CONFIG::COINS, CTFC::CONFIG::MAX_RETRY, CTFC::CONFIG::URL

Instance Attribute Summary

Attributes inherited from CTFC::Data

#coins, #count, #data, #fiat, #prices, #response, #table, #url

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CTFC::Data

#get, #price, #print=, #print?, #save=, #save?, #success?

Constructor Details

#initialize(currency = :eur, opts = {}) ⇒ Ctfc

TODO:

Allow Ctfc to use proxy and/or tor

Returns a new instance of Ctfc.



15
16
17
18
# File 'lib/ctfc.rb', line 15

def initialize(currency = :eur, opts = {})
  opts[:coins] ||= COINS
  super(currency, opts)
end

Class Method Details

.to(currency, opts = {}) ⇒ Hash

Returns CTFC::Data#prices || CTFC::Data#response.

Examples:

Get EUR data for BTC, XMR, LTC, ETH, print but don’t save output


Ctfc.to :eur, save: false, coins: %w[BTC XMR LTC ETH]

Parameters:

  • currency (Symbol)

    Required. Define fiat currency.

  • opts (Hash) (defaults to: {})

    Optional. Additional options hash.

Options Hash (opts):

  • print (Boolean)

    Optional. Print terminal output.

  • save (Boolean)

    Optional. Save ‘.csv` output.

  • coins (Array)

    Optional. Define coins to scrap.

Returns:

  • (Hash)

    CTFC::Data#prices || CTFC::Data#response



34
35
36
# File 'lib/ctfc.rb', line 34

def self.to(currency, opts = {})
  new(currency.to_sym, opts).get
end