るりまサーチ

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 > >>

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

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

...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 (26130.0)

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
# => -: fals...

ARGF.class#each_char -> Enumerator (14162.0)

レシーバに含まれる文字を一文字ずつブロックに渡して評価します。

...クトを生成し
て返します。

例:
# $ echo "line1\n" > test1.txt
# $ echo "line2\n" > test2.txt
# $ ruby test.rb test1.txt test2.txt

# test.rb
ARGF.each_char # => #<Enumerator: ARGF:each_char>
ARGF.each_char{|e|p e}

# => "l"
# "i"
# "n"
# "e"
#...
..."1"
# "\n"
# "l"
# "i"
# "n"
# "e"
# "2"
# "\n"

@see IO#each_char...

ARGF.class#each_char { |c| ... } -> self (14162.0)

レシーバに含まれる文字を一文字ずつブロックに渡して評価します。

...クトを生成し
て返します。

例:
# $ echo "line1\n" > test1.txt
# $ echo "line2\n" > test2.txt
# $ ruby test.rb test1.txt test2.txt

# test.rb
ARGF.each_char # => #<Enumerator: ARGF:each_char>
ARGF.each_char{|e|p e}

# => "l"
# "i"
# "n"
# "e"
#...
..."1"
# "\n"
# "l"
# "i"
# "n"
# "e"
# "2"
# "\n"

@see IO#each_char...

ARGF.class#each_codepoint -> Enumerator (14156.0)

self の各コードポイントに対して繰り返しブロックを呼びだします。

...numerator を返します。

例:
# $ 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,10...

絞り込み条件を変える

ARGF.class#each_codepoint { |c| ... } -> self (14156.0)

self の各コードポイントに対して繰り返しブロックを呼びだします。

...numerator を返します。

例:
# $ 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,10...

ARGF.class#inplace_mode -> String | nil (8120.0)

c:ARGF#inplace で書き換えるファイルのバックアップに付加される拡 張子を返します。拡張子が設定されていない場合は空文字列を返します。イン プレースモードでない場合は nil を返します。

...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.#lambda -> Proc (8048.0)

与えられたブロックから手続きオブジェクト (Proc のインスタンス) を生成して返します。Proc.new に近い働きをします。

...出しブロックとして振舞う際の制限です。

//emlist[問題なし][ruby]{
(1..5).each { break }
//}

//emlist[LocalJumpError が発生します。][ruby]{
pr = Proc.new { break }
(1..5).each(&pr)
//}

===[a:lambda_proc] lambda と proc と Proc.new とイテレータの違い

Kernel....
...ruby]{
def test_proc
f = Proc.new { return :from_proc }
f.call
return :from_method
end

def test_lambda
f = lambda { return :from_lambda }
f.call
return :from_method
end

def test_block
tap { return :from_block }
return :from_method
end

p test_proc() #=> :from_proc
p test_lambda()...
...#=> :from_method
p test_block() #=> :from_block
//}

以下の表は、手続きオブジェクトの実行を上の例と同じように、手続きオブジェクトが定義されたのと
同じメソッド内で行った場合の結果です。

return...

Kernel.#lambda { ... } -> Proc (8048.0)

与えられたブロックから手続きオブジェクト (Proc のインスタンス) を生成して返します。Proc.new に近い働きをします。

...出しブロックとして振舞う際の制限です。

//emlist[問題なし][ruby]{
(1..5).each { break }
//}

//emlist[LocalJumpError が発生します。][ruby]{
pr = Proc.new { break }
(1..5).each(&pr)
//}

===[a:lambda_proc] lambda と proc と Proc.new とイテレータの違い

Kernel....
...ruby]{
def test_proc
f = Proc.new { return :from_proc }
f.call
return :from_method
end

def test_lambda
f = lambda { return :from_lambda }
f.call
return :from_method
end

def test_block
tap { return :from_block }
return :from_method
end

p test_proc() #=> :from_proc
p test_lambda()...
...#=> :from_method
p test_block() #=> :from_block
//}

以下の表は、手続きオブジェクトの実行を上の例と同じように、手続きオブジェクトが定義されたのと
同じメソッド内で行った場合の結果です。

return...

Kernel.#proc -> Proc (8048.0)

与えられたブロックから手続きオブジェクト (Proc のインスタンス) を生成して返します。Proc.new に近い働きをします。

...出しブロックとして振舞う際の制限です。

//emlist[問題なし][ruby]{
(1..5).each { break }
//}

//emlist[LocalJumpError が発生します。][ruby]{
pr = Proc.new { break }
(1..5).each(&pr)
//}

===[a:lambda_proc] lambda と proc と Proc.new とイテレータの違い

Kernel....
...ruby]{
def test_proc
f = Proc.new { return :from_proc }
f.call
return :from_method
end

def test_lambda
f = lambda { return :from_lambda }
f.call
return :from_method
end

def test_block
tap { return :from_block }
return :from_method
end

p test_proc() #=> :from_proc
p test_lambda()...
...#=> :from_method
p test_block() #=> :from_block
//}

以下の表は、手続きオブジェクトの実行を上の例と同じように、手続きオブジェクトが定義されたのと
同じメソッド内で行った場合の結果です。

return...

絞り込み条件を変える

<< 1 2 > >>