class StockMarkit::ChartResult
@author Michael Heijmans (parabuzzle@gmail.com)
- Copyright
-
Copyright © 2016 Michael Heijmans
- License
-
MIT
Public Class Methods
new(json)
click to toggle source
@param [Hash] the parsed json result from the chart api
# File lib/stock-markit/chart_result.rb, line 14 def initialize(json) @json = json end
Public Instance Methods
dates()
click to toggle source
@return [Array] Timestamps corresponding to each position in UTC
# File lib/stock-markit/chart_result.rb, line 29 def dates @json["Dates"].map { |date| parse_date(date) } end
elements()
click to toggle source
@return [Array] requested element data
# File lib/stock-markit/chart_result.rb, line 34 def elements @json["Elements"] end
labels()
click to toggle source
@return [Hash] X Axis label position, text, and dates. The “dates” are in Microsoft “OA Date” format. The “text” is an ISO timestamp.
# File lib/stock-markit/chart_result.rb, line 19 def labels @json["Labels"] end
positions()
click to toggle source
@return [Array] List of X coordinate positions for each data point returned, between 0 and 1.
# File lib/stock-markit/chart_result.rb, line 24 def positions @json["Positions"] end
Private Instance Methods
parse_date(date)
click to toggle source
# File lib/stock-markit/chart_result.rb, line 41 def parse_date(date) timezone = ActiveSupport::TimeZone["Eastern Time (US & Canada)"] timezone.parse(date).utc end