Class: Barchart::History
- Defined in:
- lib/barchart/resources/history.rb
Instance Attribute Summary
Attributes inherited from Resource
Class Method Summary collapse
-
.get!(symbol, start_date = Date.today, end_date = nil) ⇒ Object
see the API documentation for values for type.
Methods inherited from Resource
#as_json, #initialize, initialize_from_array_response, #inspect, #method_missing
Constructor Details
This class inherits a constructor from Barchart::Resource
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Barchart::Resource
Class Method Details
.get!(symbol, start_date = Date.today, end_date = nil) ⇒ Object
see the API documentation for values for type
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/barchart/resources/history.rb', line 11 def self.get!(symbol, start_date=Date.today, end_date=nil) start_date_query = "startDate=#{start_date.strftime('%Y%m%d')}" if start_date end_date_query = "endDate=#{end_date.strftime('%Y%m%d')}" if end_date symbol_query = "symbol=#{symbol}" type_query = "type=daily" params = [symbol_query, type_query, start_date_query, end_date_query].compact.join('&') response = Request.get("/getHistory.json?#{params}") response[:results].map { |result| History.new(result) } end |