File tree Expand file tree Collapse file tree 5 files changed +7
-7
lines changed
lib/concurrent-ruby/concurrent Expand file tree Collapse file tree 5 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ require 'open-uri'
22
22
def get_year_end_closing (symbol , year , api_key )
23
23
uri = " https://www.alphavantage.co/query?function=TIME_SERIES_MONTHLY&symbol=#{ symbol } &apikey=#{ api_key } &datatype=csv"
24
24
data = []
25
- open (uri) do |f |
25
+ URI . open (uri) do |f |
26
26
CSV .parse(f, headers: true ) do |row |
27
27
data << row[' close' ] if row[' timestamp' ].include?(year.to_s)
28
28
end
Original file line number Diff line number Diff line change @@ -22,12 +22,12 @@ A fulfilled example:
22
22
``` ruby
23
23
require ' concurrent'
24
24
require ' thread' # for Queue
25
- require ' open-uri' # for open(uri)
25
+ require ' open-uri' # for URI. open(uri)
26
26
27
27
class Ticker
28
28
def get_year_end_closing (symbol , year )
29
29
uri = " http://ichart.finance.yahoo.com/table.csv?s=#{ symbol } &a=11&b=01&c=#{ year } &d=11&e=31&f=#{ year } &g=m"
30
- data = open (uri) {|f | f.collect{|line | line.strip } }
30
+ data = URI . open (uri) {|f | f.collect{|line | line.strip } }
31
31
data[1 ].split(' ,' )[4 ].to_f
32
32
end
33
33
end
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ require 'open-uri'
35
35
def get_year_end_closing (symbol , year , api_key )
36
36
uri = " https://www.alphavantage.co/query?function=TIME_SERIES_MONTHLY&symbol=#{ symbol } &apikey=#{ api_key } &datatype=csv"
37
37
data = []
38
- open (uri) do |f |
38
+ URI . open (uri) do |f |
39
39
CSV .parse(f, headers: true ) do |row |
40
40
data << row[' close' ] if row[' timestamp' ].include?(year.to_s)
41
41
end
Original file line number Diff line number Diff line change 5
5
def get_year_end_closing ( symbol , year , api_key )
6
6
uri = "https://www.alphavantage.co/query?function=TIME_SERIES_MONTHLY&symbol=#{ symbol } &apikey=#{ api_key } &datatype=csv"
7
7
data = [ ]
8
- open ( uri ) do |f |
8
+ URI . open ( uri ) do |f |
9
9
CSV . parse ( f , headers : true ) do |row |
10
10
data << row [ 'close' ] if row [ 'timestamp' ] . include? ( year . to_s )
11
11
end
Original file line number Diff line number Diff line change @@ -59,12 +59,12 @@ module Concurrent
59
59
#
60
60
# require 'concurrent'
61
61
# require 'thread' # for Queue
62
- # require 'open-uri' # for open(uri)
62
+ # require 'open-uri' # for URI. open(uri)
63
63
#
64
64
# class Ticker
65
65
# def get_year_end_closing(symbol, year)
66
66
# uri = "http://ichart.finance.yahoo.com/table.csv?s=#{symbol}&a=11&b=01&c=#{year}&d=11&e=31&f=#{year}&g=m"
67
- # data = open(uri) {|f| f.collect{|line| line.strip } }
67
+ # data = URI. open(uri) {|f| f.collect{|line| line.strip } }
68
68
# data[1].split(',')[4].to_f
69
69
# end
70
70
# end
You can’t perform that action at this time.
0 commit comments