'ruby'에 해당되는 글 2건

  1. 2011.01.08 [Ruby] Save image from web
  2. 2011.01.07 [Ruby] Simple file copy example
Coding/Ruby2011. 1. 8. 02:08
# save image from web
# 2011. 1. 7

require 'open-uri'

def read_url_file(url_name_, number_)
    open(url_name_) { |from| $data = from.read }
    File.open("#{number_}.jpg", "wb:binary") { |to| to.write($data) }
end

read_url_file("http://chobocho.com/photo/sydney.jpg", 2)

'Coding > Ruby' 카테고리의 다른 글

[Ruby] Simple file copy example  (0) 2011.01.07
Posted by chobocho
Coding/Ruby2011. 1. 7. 23:48
# simple file copy
# 2011. 1. 7

File.open("test.png", "rb:binary") { |from| $data = from.read }
File.open("test2.png", "wb:binary") { |to| to.write($data) }

'Coding > Ruby' 카테고리의 다른 글

[Ruby] Save image from web  (0) 2011.01.08
Posted by chobocho