Module: HG::Finance

Defined in:
lib/hg/finance.rb,
lib/hg/finance/data.rb,
lib/hg/finance/stock.rb,
lib/hg/finance/taxes.rb,
lib/hg/finance/locale.rb,
lib/hg/finance/version.rb,
lib/hg/finance/currency.rb

Defined Under Namespace

Classes: Currency, Data, Locale, Stock, Taxes

Constant Summary collapse

HOST_NAME =
'://api.hgbrasil.com/finance'
VERSION =
"1.0.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_keyObject

API Key



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

def api_key
  @api_key
end

.api_key_statusObject (readonly)

API Key status



19
20
21
# File 'lib/hg/finance.rb', line 19

def api_key_status
  @api_key_status
end

.localeObject

Locale



16
17
18
# File 'lib/hg/finance.rb', line 16

def locale
  @locale
end

.use_rails_cacheObject

Use Rails cache for recieved data (realy recommended)



25
26
27
# File 'lib/hg/finance.rb', line 25

def use_rails_cache
  @use_rails_cache
end

.use_sslObject

Use SSL to access the API



22
23
24
# File 'lib/hg/finance.rb', line 22

def use_ssl
  @use_ssl
end

Class Method Details

.defaultsObject



50
51
52
53
54
55
56
57
# File 'lib/hg/finance.rb', line 50

def self.defaults
  {
    key: self.api_key,
    locale: self.locale,
    format: :json,
    sdk_version: "ruby_f#{HG::Finance::VERSION}"
  }
end

.get(options = {}) ⇒ Object



40
41
42
# File 'lib/hg/finance.rb', line 40

def self.get(options = {})
  process({})
end

.process(params) ⇒ Object



44
45
46
47
48
# File 'lib/hg/finance.rb', line 44

def self.process params
  params = defaults.merge(params).delete_if{|k,v| v.nil?}

  return HG::Finance::Data.new(params, HOST_NAME, self.use_ssl)
end

.setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (HG::Finance)

    the object that the method was called on



36
37
38
# File 'lib/hg/finance.rb', line 36

def self.setup(&block)
  yield self
end