るりまサーチ

最速Rubyリファレンスマニュアル検索!
172件ヒット [1-100件を表示] (0.067秒)

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method new
  4. irb/input-method gets
  5. matrix -

クラス

モジュール

キーワード

検索結果

<< 1 2 > >>

Kernel.#test(cmd, file) -> bool | Time | Integer | nil (18350.0)

単体のファイルでファイルテストを行います。

...: ?z
ファイルサイズが 0 である
: ?s
ファイルサイズが 0 でない (ファイルサイズを返す、0 ならば nil) -> Integer|nil
: ?f
ファイルはプレーンファイルである
: ?d
ファイルはディレクトリである
: ?l
ファイルはシン...
...を返す -> Time
: ?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...

Kernel.#test(cmd, file1, file2) -> bool (18230.0)

2ファイル間のファイルテストを行います。

...ル2より最終更新時刻が古い
: ?-
ファイル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...

FileTest.#size?(file) -> Integer | nil (3209.0)

ファイルのサイズを返します。ファイルが存在しない時や ファイルのサイズが0の時には nil を返します。

...定された IO オブジェクト file が既に close されていた場合に発生します。

//emlist[例][ruby]{
IO.write("testfile", "test")
FileTest.size?("testfile") # => 4
File.delete("testfile")
FileTest.size?("testfile") # => nil
//}

@see FileTest.#size, FileTest.#zero?...

FileTest.#size(file) -> Integer (3203.0)

ファイルのサイズを返します。

...しない場合、あるいはシステムコールに失敗した場合に発生します。

@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。

@see FileTest.#size?, FileTest.#zero?

例:
FileTest.size('/etc/passwd') # => 5925...

FileTest.#world_readable?(path) -> Integer | nil (3203.0)

path が全てのユーザから読めるならばそのファイルのパーミッションを表す 整数を返します。そうでない場合は nil を返します。

...整数を返します。そうでない場合は nil を返します。

整数の意味はプラットフォームに依存します。

@param path パスを表す文字列を指定します。

m = FileTest.world_readable?("/etc/passwd")
"%o" % m # => "644"...

絞り込み条件を変える

Module#const_source_location(name, inherited = true) -> [String, Integer] (263.0)

name で指定した定数の定義を含むソースコードのファイル名と行番号を配列で返します。

...ruby]{
# test.rb:
class A # line 1
C1 = 1
C2 = 2
end

module M # line 6
C3 = 3
end

class B < A # line 10
include M
C4 = 4
end

class A # 継続して A を定義する
C2 = 8 # 定数を再定義する
end

p B.const_source_location('C4') # => ["test.rb", 12...
...tion('C3') # => ["test.rb", 7]
p B.const_source_location('C1') # => ["test.rb", 2]

p B.const_source_location('C3', false) # => nil -- include したモジュールは検索しない

p A.const_source_location('C2') # => ["test.rb", 16] -- 最後に定義された...
...) # => ["test.rb", 10] -- Object はトップレベルの定数を検索する
p Object.const_source_location('A') # => ["test.rb", 1] -- クラスが再定義された場合は最初の定義位置を返す

p B.const_source_location('A') # => ["test.rb", 1] -- Object を継...

File.delete(*filename) -> Integer (252.0)

ファイルを削除します。削除したファイルの数を返します。 削除に失敗した場合は例外 Errno::EXXX が発生します。

...

//emlist[例][ruby]{
IO.write("test.txt", "test")
p File.exist?("test.txt") # => true
p File.delete("test.txt") # => 1
p File.exist?("test.txt") # => false
begin
File.delete("test.txt")
rescue
p $! # => #<Errno::ENOENT: No such file or directory @ unlink_internal - test.txt>
end
//}...

File.unlink(*filename) -> Integer (252.0)

ファイルを削除します。削除したファイルの数を返します。 削除に失敗した場合は例外 Errno::EXXX が発生します。

...

//emlist[例][ruby]{
IO.write("test.txt", "test")
p File.exist?("test.txt") # => true
p File.delete("test.txt") # => 1
p File.exist?("test.txt") # => false
begin
File.delete("test.txt")
rescue
p $! # => #<Errno::ENOENT: No such file or directory @ unlink_internal - test.txt>
end
//}...

File.chown(owner, group, *filename) -> Integer (239.0)

ファイルのオーナーとグループを変更します。スーパーユーザだけがファ イルのオーナーとグループを変更できます。変更を行ったファイルの数を 返します。

...er chown(2) と同様に数値で指定します。nil または -1 を指定することで、オーナーを現在のままにすることができます。

@param group chown(2) と同様に数値で指定します。nil または -1 を指定することで、グループを現在のままに...
...することができます。

@raise Errno::EXXX 変更に失敗した場合に発生します。

//emlist[例][ruby]{
IO.write("test.txt", "test")
File.chown(502, 12, "test.txt")
File.stat("test.txt").uid # => 502
//}

@see File#chown...

File.lchown(owner, group, *filename) -> Integer (233.0)

File#chown と同様ですが、 シンボリックリンクに関してリンクそのもののオーナー、 グループを変更します。

...er chown(2) と同様に数値で指定します。nil または -1 を指定することで、オーナーを現在のままにすることができます。

@param group chown(2) と同様に数値で指定します。nil または -1 を指定することで、グループを現在のままに...
...発生します。

//emlist[例][ruby]{
IO.write("testfile", "test")
File.symlink("testfile", "testlink")
File.chown(501, -1, "testfile")
File.lstat("testlink").ftype # => "link"
File.lchown(0, -1, "testlink")
File.stat("testlink").uid # => 501
File.lstat("testlink").uid # => 0
//}...

絞り込み条件を変える

<< 1 2 > >>