Class: StockMarkit::ChartResult

Inherits:
Object
  • Object
show all
Defined in:
lib/stock-markit/chart_result.rb

Overview

Stock Chart Result Object

Copyright

Copyright © 2016 Michael Heijmans

License

MIT

Author:

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ ChartResult

Returns a new instance of ChartResult.

Parameters:

  • the (Hash)

    parsed json result from the chart api


14
15
16
# File 'lib/stock-markit/chart_result.rb', line 14

def initialize(json)
  @json = json
end

Instance Method Details

#datesArray

Returns Timestamps corresponding to each position in UTC.

Returns:

  • (Array)

    Timestamps corresponding to each position in UTC


29
30
31
# File 'lib/stock-markit/chart_result.rb', line 29

def dates
  @json["Dates"].map { |date| parse_date(date) }
end

#elementsArray

Returns requested element data.

Returns:

  • (Array)

    requested element data


34
35
36
# File 'lib/stock-markit/chart_result.rb', line 34

def elements
  @json["Elements"]
end

#labelsHash

Returns X Axis label position, text, and dates. The “dates” are in Microsoft “OA Date” format. The “text” is an ISO timestamp.

Returns:

  • (Hash)

    X Axis label position, text, and dates. The “dates” are in Microsoft “OA Date” format. The “text” is an ISO timestamp.


19
20
21
# File 'lib/stock-markit/chart_result.rb', line 19

def labels
  @json["Labels"]
end

#positionsArray

Returns List of X coordinate positions for each data point returned, between 0 and 1.

Returns:

  • (Array)

    List of X coordinate positions for each data point returned, between 0 and 1.


24
25
26
# File 'lib/stock-markit/chart_result.rb', line 24

def positions
  @json["Positions"]
end