I need to get the path of the file in fo variable so that i can pass the path to the unzip_file function. how do i get the path here?
url = 'http://www.dtniq.com/product/mktsymbols_v2.zip'
open(url, 'r') do |fo|
puts "unzipfile "
unzip_file(fo, "c:\\temp11\\")
end
In terms of how to do it I would do this:
Find out the class of the object I am dealing with
ruby-1.9.2-p290 :001 > tmp_file = open('tmp.txt', 'r') => #<File:tmp.txt> ruby-1.9.2-p290 :001 > tmp_file.class => File
Go look up the documentation for that class
Google Search : ruby file
Which returns Class: File ruby-doc.org
=> www.ruby-doc.org/core/classes/File.html
Look at the methods. There is one called path
-> looks interesting
If I haven't found an answer by now then
Most of the time 1..3
should get you what you need. Once you learn to read the documentation you can do things a lot quicker. It's just trying to overcome how difficult it is to get into the docs when you first start.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.