Class: FundamentusData

Inherits:
Object
  • Object
show all
Defined in:
lib/fundamentus_data/fundamentus_data.rb

Class Method Summary collapse

Class Method Details

.save(stock_codes, destination_path, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fundamentus_data/fundamentus_data.rb', line 7

def self.save(stock_codes, destination_path, options = {})
  destination_path = File.expand_path(destination_path, Dir.pwd) + '/'

  fetcher = options[:fetcher] || UrlFetcher.new(options)

  file_manager = FileManager.new(destination_path, options)
  parser = FundamentusParser.new(options)

  pages = FundamentusFetcher.new(fetcher, options).fetch(stock_codes)
  pages.each do |key, content|
    file_manager.save(key + '.json', parser.parse(content).to_json)
  end
end