2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

rubyでファイルをダウンロード

Posted at

後で見直すためにメモ

ファイルを保存する

URLを指定してファイルを保存する

hoge.rb
# pathも指定する
filename = "hoge/hoge.rb"
url = "http://hoge.com"
open(url) do |file|
  open(filename, "w+b") do |out|
    out.write(file.read)
  end
end

時刻を扱う

hoge.rb
t = Time.now
t.year
t.month
t.day
t.hour
t.min
t.sec
t.usec

こんな感じで各種時刻を出力
ファイル名などに時刻を入れたい場合に使用

まとめ

たまにやり方を探す時に探すのが面倒くさいからメモ

2
2
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?