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'
2222def get_year_end_closing (symbol , year , api_key )
2323 uri = " https://www.alphavantage.co/query?function=TIME_SERIES_MONTHLY&symbol=#{ symbol } &apikey=#{ api_key } &datatype=csv"
2424 data = []
25- open (uri) do |f |
25+ URI . open (uri) do |f |
2626 CSV .parse(f, headers: true ) do |row |
2727 data << row[' close' ] if row[' timestamp' ].include?(year.to_s)
2828 end
Original file line number Diff line number Diff line change @@ -22,12 +22,12 @@ A fulfilled example:
2222``` ruby
2323require ' concurrent'
2424require ' thread' # for Queue
25- require ' open-uri' # for open(uri)
25+ require ' open-uri' # for URI. open(uri)
2626
2727class Ticker
2828 def get_year_end_closing (symbol , year )
2929 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 } }
3131 data[1 ].split(' ,' )[4 ].to_f
3232 end
3333end
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ require 'open-uri'
3535def get_year_end_closing (symbol , year , api_key )
3636 uri = " https://www.alphavantage.co/query?function=TIME_SERIES_MONTHLY&symbol=#{ symbol } &apikey=#{ api_key } &datatype=csv"
3737 data = []
38- open (uri) do |f |
38+ URI . open (uri) do |f |
3939 CSV .parse(f, headers: true ) do |row |
4040 data << row[' close' ] if row[' timestamp' ].include?(year.to_s)
4141 end
Original file line number Diff line number Diff line change 55def get_year_end_closing ( symbol , year , api_key )
66 uri = "https://www.alphavantage.co/query?function=TIME_SERIES_MONTHLY&symbol=#{ symbol } &apikey=#{ api_key } &datatype=csv"
77 data = [ ]
8- open ( uri ) do |f |
8+ URI . open ( uri ) do |f |
99 CSV . parse ( f , headers : true ) do |row |
1010 data << row [ 'close' ] if row [ 'timestamp' ] . include? ( year . to_s )
1111 end
Original file line number Diff line number Diff line change @@ -59,12 +59,12 @@ module Concurrent
5959 #
6060 # require 'concurrent'
6161 # require 'thread' # for Queue
62- # require 'open-uri' # for open(uri)
62+ # require 'open-uri' # for URI. open(uri)
6363 #
6464 # class Ticker
6565 # def get_year_end_closing(symbol, year)
6666 # 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 } }
6868 # data[1].split(',')[4].to_f
6969 # end
7070 # end
You can’t perform that action at this time.
0 commit comments