Sha256: 487c46398420172c060c921862105cb6dacef79d42c1e8baade726124ccbe107

Contents?: true

Size: 592 Bytes

Versions: 1

Compression:

Stored size: 592 Bytes

Contents

module Barchart
  # http://www.barchartondemand.com/api/getQuote
  class Quote < Resource
    # mode can be R (realtime), I (delayed), D (end-of-day)
    def self.get!(symbols, fields=[:bid,:ask], mode='R')
      fields_query = fields.join(',')

      symbols_query = symbols
      symbols_query = symbols.join(',')  if symbols.is_a?(Array)

      response = Request.get("/getQuote.json?symbols=#{symbols_query}&fields=#{fields_query}")

      return Quote.new(response[:results].first)  if symbols.is_a?(String)
      response[:results].map { |result| Quote.new(result) }
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
barchart-0.0.1 lib/barchart/resources/quote.rb