Class: YahooStock::History

Inherits:
Base
  • Object
show all
Defined in:
lib/yahoo_stock/history.rb

Defined Under Namespace

Classes: HistoryError

Instance Method Summary collapse

Methods inherited from Base

#results

Constructor Details

#initialize(options) ⇒ History

Returns a new instance of History


6
7
8
9
10
11
# File 'lib/yahoo_stock/history.rb', line 6

def initialize(options)
  unless options.is_a?(Hash)
    raise HistoryError, 'A hash of start_date, end_date and stock_symbol is expected as parameters'
  end
  @interface = YahooStock::Interface::History.new(options)
end

Instance Method Details

#data_attributesObject


22
23
24
25
26
27
28
29
# File 'lib/yahoo_stock/history.rb', line 22

def data_attributes
  return unless values_with_header
  data_attributes = /Date.*\s/.match(values_with_header)
  unless data_attributes.nil?
    @data_attributes = data_attributes[0].sub(/\s*$/,'').split(',')
    @data_attributes.map &:strip
  end
end

#findObject


13
14
15
16
# File 'lib/yahoo_stock/history.rb', line 13

def find
  @find_values = super()
  @find_values.sub(/Date.*\s/,'') if @find_values
end

#values_with_headerObject


18
19
20
# File 'lib/yahoo_stock/history.rb', line 18

def values_with_header
  @interface.values
end