Class: StockCruncher::Cruncher

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

Overview

This is an data cruncher abstract class.

Direct Known Subclasses

AlphaVantage

Instance Method Summary collapse

Constructor Details

#initialize(config, insecure = false) ⇒ Cruncher

Class constructor method



10
11
12
13
# File 'lib/stockcruncher/cruncher.rb', line 10

def initialize(config, insecure = false)
  @config = config
  @insecure = insecure
end

Instance Method Details

#request(url) ⇒ Object

Method to send http get request



16
17
18
19
20
21
22
23
# File 'lib/stockcruncher/cruncher.rb', line 16

def request(url)
  uri = URI.parse(url)
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = uri.scheme.eql?('https')
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE if @insecure
  req = Net::HTTP::Get.new(uri.request_uri)
  http.request(req)
end