別のキーワード
種類
- モジュール関数 (223)
- インスタンスメソッド (217)
- 特異メソッド (104)
- クラス (11)
クラス
-
ARGF
. class (79) - Binding (6)
- Dir (11)
- Exception (29)
- File (88)
- IO (33)
- Method (10)
- Module (5)
-
ObjectSpace
:: WeakMap (11) - String (27)
- TracePoint (22)
キーワード
- Proc (11)
- []= (11)
-
backtrace
_ locations (11) -
caller
_ locations (22) - chomp (11)
- chop (11)
- chown (11)
- chr (11)
-
const
_ source _ location (5) - delete (11)
- dup (11)
-
each
_ char (22) -
each
_ codepoint (22) - empty? (8)
- getc (11)
- gets (24)
- grpowned? (11)
- gsub (33)
- identical? (11)
-
inplace
_ mode (11) - inspect (16)
- lambda (17)
- lchown (11)
- new (27)
- open (22)
- path (11)
- pipe? (11)
- proc (18)
- puts (11)
- read (11)
- readlink (11)
-
set
_ backtrace (11) - socket? (11)
-
source
_ location (6) -
to
_ s (5) - unlink (11)
- warn (7)
-
world
_ readable? (11) -
world
_ writable? (11) - zero? (8)
検索結果
先頭5件
-
Kernel
. # test(cmd , file) -> bool | Time | Integer | nil (18137.0) -
単体のファイルでファイルテストを行います。
...ルでファイルテストを行います。
@param cmd 以下に示す文字リテラル、文字列、あるいは同じ文字を表す数値
です。文字列の場合はその先頭の文字だけをコマンドとみなします。
@param file テストするファイルのパス......プレーンファイルである
: ?d
ファイルはディレクトリである
: ?l
ファイルはシンボリックリンクである
: ?p
ファイルは名前つきパイプ(FIFO)である
: ?S
ファイルはソケットである
: ?b
ファイルはブロックスペシ......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
. # test(cmd , file1 , file2) -> bool (18127.0) -
2ファイル間のファイルテストを行います。
...間のファイルテストを行います。
@param cmd 以下に示す文字リテラル、文字列、あるいは同じ文字を表す数値
です。文字列の場合はその先頭の文字だけをコマンドとみなします。
@param file1 テストするファイルのパス......を表す文字列か IO オブジェクトを指定します。
@param file2 テストするファイルのパスを表す文字列か IO オブジェクトを指定します。
@return 真偽値を返します。
以下は cmd として指定できる文字リテラルとその意味です。
:......イル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
. # empty?(file) -> bool (9102.0) -
ファイルが存在して、そのサイズが 0 である時に真を返します。 そうでない場合、あるいはシステムコールに失敗した場合には false を返します。
...返します。
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。
//emlist[例:][ruby]{
IO.write("zero.txt", "")
FileTest.zero?("zero.txt"......) # => true
IO.write("nonzero.txt", "1")
FileTest.zero?("nonzero.txt") # => false
//}
@see FileTest.#size, FileTest.#size?... -
FileTest
. # grpowned?(file) -> bool (9102.0) -
ファイルのグループ ID がカレントプロセスの実効グループ ID と等しい時に真を返 します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
...。
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。
//emlist[例][ruby]{
IO.write("testfile", "")
File.chown(-1, Process.gid, "testfile"......)
FileTest.grpowned?("testfile") # => true
File.chown(-1, Process.gid + 10, "testfile")
FileTest.grpowned?("testfile") # => false
//}... -
FileTest
. # pipe?(file) -> bool (9102.0) -
指定したファイルがパイプである時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
...ます。
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。
例:
r, w = IO.pipe
FileTest.pipe?(r) # => true
FileTest.pipe?(w) # => t... -
ARGF
. class # inplace _ mode -> String | nil (6210.0) -
c:ARGF#inplace で書き換えるファイルのバックアップに付加される拡 張子を返します。拡張子が設定されていない場合は空文字列を返します。イン プレースモードでない場合は nil を返します。
...c:ARGF#inplace で書き換えるファイルのバックアップに付加される拡
張子を返します。拡張子が設定されていない場合は空文字列を返します。イン
プレースモードでない場合は nil を返します。
Ruby 起動時の -i オプション や......F.class#inplace_mode= で設定します。
例:
# $ echo "test" > test.txt
# $ ruby -i.bak test.rb test.txt
# $ cat test.txt # => "TEST"
# $ cat test.txt.bak # => "test"
# test.rb
ARGF.inplace_mode # => ".bak"
ARGF.each_line {|e|print e.upcase} # => "TEST"
例:......# $ echo "test" > test.txt
# $ ruby test.rb test.txt
# $ cat test.txt # => "test"
# test.rb
ARGF.inplace_mode # => nil
ARGF.each_line {|e|print e.upcase} # => "TEST"
@see d:spec/rubycmd#cmd_option, ARGF.class#inplace_mode=... -
Kernel
. # chop -> String (6166.0) -
$_.chop とほぼ同じですが、置換が発生したときは、$_の内容を置き換える点が異なります。 コマンドラインオプションで -p または -n を指定した時のみ定義されます。
...$_.chop とほぼ同じですが、置換が発生したときは、$_の内容を置き換える点が異なります。
コマンドラインオプションで -p または -n を指定した時のみ定義されます。
暗号的になりすぎるきらいがあるため、このメソッド......$_.chop を使ってください。
$_.chopとこのメソッド chop は以下の点で違いがあります。
* chop は $_ の値をコピーして、コピーの方を更新し、
$_ に再代入します。
//emlist[例][ruby]{
$_ = "test\r\n"
$_ # => "test\r\n"
chop #......=> "test"
$_ = "test\n"
$_ # => "test\n"
chop # => "test"
$_ = "test"
$_ # => "test"
chop # => "tes"
//}
@see String#chop,$_... -
Kernel
. # chomp(rs = $ / ) -> String (6160.0) -
$_.chomp とほぼ同じですが、置換が発生したときは、$_の内容を置き換える点が異なります。 コマンドラインオプションで -p または -n を指定した時のみ定義されます。
...$_.chomp とほぼ同じですが、置換が発生したときは、$_の内容を置き換える点が異なります。
コマンドラインオプションで -p または -n を指定した時のみ定義されます。
暗号的になりすぎるきらいがあるため、このメソッド......。
今後はより明示的な $_.chomp を使ってください。
$_.chomp とこのメソッド chomp は以下の点で違いがあります。
* chomp は $_ の値をコピーして、コピーの方を更新し、
$_ に再代入します。
@param rs 末尾から削除する改行コ......//emlist[例: ruby -n で "test" を入力][ruby]{
$_ # => "test\n"
chomp # => "test"
//}
//emlist[例: ruby -n で "test," を入力し、 rs に "," を指定][ruby]{
$_ # => "test\n"
chomp # => "test,"
chomp(",") # => "test"
//}
@see String#chomp,$_,$/... -
Method
# inspect -> String (6150.0) -
self を読みやすい文字列として返します。
...の文字列を返します。
#<Method: klass1(klass2)#method(arg) foo.rb:2> (形式1)
klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクトの生成
元となったクラス/モジュール名です。
klass2......oo
def foo
"foo"
end
end
class Bar
include Foo
def bar(a, b)
end
end
p Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo() test.rb:2>
p Bar.new.method(:bar) # => #<Method: Bar#bar(a, b) test.rb:8>
//}
klass1 と klass2 が同じ場合は以下の形式になります。......end
end
p obj.method(:foo) # => #<Method: "".foo() foo.rb:4>
# クラスメソッド(クラスの特異メソッド)
class Foo
def Foo.foo
end
end
p Foo.method(:foo) # => #<Method: Foo.foo() foo.rb:11>
# スーパークラスのクラスメソッド
class Bar < Foo
end
p Bar.metho... -
ARGF
. class # each _ codepoint -> Enumerator (6138.0) -
self の各コードポイントに対して繰り返しブロックを呼びだします。
...or を返します。
例:
# $ echo "line1\n" > test1.txt
# $ echo "line2\n" > test2.txt
# $ ruby test.rb test1.txt test2.txt
# test.rb
ARGF.each_codepoint # => #<Enumerator: ARGF:each_codepoint>
ARGF.each_codepoint{|e|print e, ","} # => 108,105,110,101,49,10,108,105,1...