74件ヒット
[1-74件を表示]
(0.013秒)
種類
- 変数 (33)
- モジュール関数 (30)
- インスタンスメソッド (11)
検索結果
先頭5件
-
Kernel
# file(*args) { . . . } -> Rake :: FileTask (18214.0) -
ファイルタスクを定義します。
...名と依存ファイル名を指定します。
例:
file "config.cfg" => ["config.template"] do
open("config.cfg", "w") do |outfile|
open("config.template") do |infile|
while line = infile.gets
outfile.puts line
end
end
end
end
@see Rake... -
Kernel
. # test(cmd , file1 , file2) -> bool (223.0) -
2ファイル間のファイルテストを行います。
...文字列の場合はその先頭の文字だけをコマンドとみなします。
@param file1 テストするファイルのパスを表す文字列か IO オブジェクトを指定します。
@param file2 テストするファイルのパスを表す文字列か IO オブジェクトを指定......イル1とファイル2が同一のファイルである
//emlist[例][ruby]{
IO.write("testfile1", "test1")
IO.write("testfile2", "test2")
%w(= < > -).each do |e|
result = test(e, "testfile1", "testfile2")
puts "#{e}: #{result}"
end
//}
# => =: true
# => <: false
# => >: false
# => -: false... -
Kernel
. # test(cmd , file) -> bool | Time | Integer | nil (113.0) -
単体のファイルでファイルテストを行います。
...るいは同じ文字を表す数値
です。文字列の場合はその先頭の文字だけをコマンドとみなします。
@param file テストするファイルのパスを表す文字列か IO オブジェクトを指定します。
@return 下表に特に明記していない......me
: ?A
ファイルの最終アクセス時刻を返す -> Time
: ?C
ファイルの inode 変更時刻を返す -> Time
//emlist[例][ruby]{
IO.write("testfile", "test")
test("r", "testfile") # => true
test("s", "testfile") # => 4
test("M", "testfile") # => 2018-03-31 07:38:40 +0900
//}... -
Kernel
. # open(name , mode = & # 39;r& # 39; , perm = nil , options = {}) -> StringIO | Tempfile | IO (107.0) -
name が http:// や ftp:// で始まっている文字列なら URI のリソースを 取得した上で StringIO オブジェクトまたは Tempfile オブジェクトとして返します。 返されるオブジェクトは OpenURI::Meta モジュールで extend されています。
...name が http:// や ftp:// で始まっている文字列なら URI のリソースを
取得した上で StringIO オブジェクトまたは Tempfile オブジェクトとして返します。
返されるオブジェクトは OpenURI::Meta モジュールで extend されています。
name......われ、従来の
Kernel.#open(name, *rest) が呼ばれます。
ブロックを与えた場合は上の場合と同様、name が http:// や ftp:// で
始まっている文字列なら URI のリソースを取得した上で StringIO オブジェクト
または Tempfile オブジェクトを......ブクラスが発生します。詳しくは net/ftp
を参照して下さい。
例:
require 'open-uri'
sio = open('http://www.example.com') { |sio|
p sio.is_a?(OpenURI::Meta) # => true
p sio.content_type
puts sio.read
}
@see OpenURI.open_uri, URI.open... -
Kernel
$ $ > -> object (25.0) -
標準出力です。
...標準出力です。
組み込み関数 Kernel.#print、Kernel.#puts や
Kernel.#p などのデフォルトの出力先となります。
初期値は Object::STDOUT です。
コマンドラインオプションオプション -i を指定した場合には
読み込み元と同じ名前のフ......ように $stdout に代入すれば十分です。
//emlist[例][ruby]{
# 標準出力の出力先を /tmp/foo に変更
$stdout = File.open("/tmp/foo", "w")
puts "foo" # 出力する
$stdout = STDOUT # 元に戻す
//}
自プロセスだけでなく、子プロセスの標準出力も......stdout_old = $stdout.dup # 元の $stdout を保存する
$stdout.reopen("/tmp/foo") # $stdout を /tmp/foo にリダイレクトする
puts "foo" # /tmp/foo に出力
$stdout.flush # 念のためフラッシュする
$stdout.reopen stdout_old... -
Kernel
$ $ stdout -> object (25.0) -
標準出力です。
...標準出力です。
組み込み関数 Kernel.#print、Kernel.#puts や
Kernel.#p などのデフォルトの出力先となります。
初期値は Object::STDOUT です。
コマンドラインオプションオプション -i を指定した場合には
読み込み元と同じ名前のフ......ように $stdout に代入すれば十分です。
//emlist[例][ruby]{
# 標準出力の出力先を /tmp/foo に変更
$stdout = File.open("/tmp/foo", "w")
puts "foo" # 出力する
$stdout = STDOUT # 元に戻す
//}
自プロセスだけでなく、子プロセスの標準出力も......stdout_old = $stdout.dup # 元の $stdout を保存する
$stdout.reopen("/tmp/foo") # $stdout を /tmp/foo にリダイレクトする
puts "foo" # /tmp/foo に出力
$stdout.flush # 念のためフラッシュする
$stdout.reopen stdout_old... -
Kernel
$ $ stderr -> object (19.0) -
標準エラー出力です。
...標準エラー出力です。
Ruby インタプリタが出力するエラーメッセージや
警告メッセージ、Kernel.#warn の出力先となります。
初期値は Object::STDERR です。
$stderr に代入するオブジェクトには
write という名前のメソッドが定義......$stderr に代入すれば十分です。
//emlist[例][ruby]{
# 標準エラー出力の出力先を /tmp/foo に変更
$stderr = File.open("/tmp/foo", "w")
puts "foo" # 出力する
$stderr = STDERR # 元に戻す
//}
自プロセスだけでなく、子プロセスの標準エラー......stderr_old = $stderr.dup # 元の $stderr を保存する
$stderr.reopen("/tmp/foo") # $stderr を /tmp/foo にリダイレクトする
puts "foo" # /tmp/foo に出力
$stderr.flush # 念のためフラッシュする
$stderr.reopen stderr_old...