class Stocktastic::Base

Main class for integrating with Stocktastic.

stocktastic = Stocktastic::Base.new
quote = stocktastic.quote('AAPL')

Attributes

adapter[R]

Returns the adapter currently in use

Public Class Methods

Stocktastic::Base.new click to toggle source
Stocktastic::Base.new(CustomAdapter.new)

Construct a new Stocktastic::Base object using the specified adapter. If no adapter is passed the default_adapter will be used.

# File lib/stocktastic/base.rb, line 19
def initialize adapter = Stocktastic::default_adapter.new
  @adapter = adapter
end

Public Instance Methods

quote(symbol) click to toggle source

Fetch quote information for a single symbol.

quote = stocktastic.quote('AAPL')
# => {:symbol => 'AAPL', :name => 'Apple Inc.', ...}
# File lib/stocktastic/base.rb, line 28
def quote symbol
  adapter.get_single_quote symbol
end
quotes(symbols) click to toggle source

Fetch quote information for many symbols.

quotes = stocktastic.quotes(['AAPL', 'GOOG'])
# => [{:symbol => 'AAPL', :name => 'Apple Inc.', ...}, {:symbol => 'GOOG', ...}]
# File lib/stocktastic/base.rb, line 37
def quotes symbols
  adapter.get_multiple_quotes symbols
end