るりまサーチ

最速Rubyリファレンスマニュアル検索!
555件ヒット [401-500件を表示] (0.085秒)

別のキーワード

  1. kernel test
  2. _builtin test
  3. rubygems/test_utilities tempio
  4. rubygems/test_utilities fetcher=
  5. testtask test_files=

ライブラリ

モジュール

キーワード

検索結果

<< < ... 3 4 5 6 > >>

Kernel.#lambda -> Proc (37.0)

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

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

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

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

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

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

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

...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...

FileUtils.#move(src, dest, options = {}) -> () (13.0)

ファイル src を dest に移動します。

...c:FileUtils#options

//emlist[][ruby]{
require 'fileutils'
FileUtils.mv('badname.rb', 'goodname.rb')
FileUtils.mv('stuff.rb', 'lib/ruby', force: true)
FileUtils.mv(['junk.txt', 'dust.txt'], "#{ENV['HOME']}/.trash")
FileUtils.mv(Dir.glob('test*.rb'), 'test', noop: true, verbose: true)
//}...

絞り込み条件を変える

FileUtils.#mv(src, dest, options = {}) -> () (13.0)

ファイル src を dest に移動します。

...c:FileUtils#options

//emlist[][ruby]{
require 'fileutils'
FileUtils.mv('badname.rb', 'goodname.rb')
FileUtils.mv('stuff.rb', 'lib/ruby', force: true)
FileUtils.mv(['junk.txt', 'dust.txt'], "#{ENV['HOME']}/.trash")
FileUtils.mv(Dir.glob('test*.rb'), 'test', noop: true, verbose: true)
//}...

JSON.#dump(object, io = nil, limit = nil) -> String | IO (13.0)

与えられたオブジェクトを JSON 形式の文字列に変換してダンプします。

...ka", age: 19 }) # => "{\"name\":\"tanaka\",\"age\":19}"
//}

//emlist[例][ruby]{
require "json"

File.open("test.txt", "w") do |f|
JSON.dump([[[[[[[[[[]]]]]]]]]], f, 10) # => #<File:test.txt>
JSON.dump([[[[[[[[[[[]]]]]]]]]]], f, 10) # => exceed depth limit (ArgumentError)
end
//}

@see Marsha...

ObjectSpace.#allocation_sourcefile(object) -> String (13.0)

objectの元となったソースファイル名を返します。

...返します。

//emlist[例:test.rbというファイルで下記のスクリプトを実行した場合][ruby]{
require 'objspace'

ObjectSpace::trace_object_allocations_start
obj = Object.new
puts "file:#{ObjectSpace::allocation_sourcefile(obj)}" # => file:test.rb
ObjectSpace::trace_object_all...

FileUtils.#mkdir(dir, options = {}) -> () (7.0)

ディレクトリ dir を作成します。

...作成するディレクトリ。

@param options :mode, :noop, :verbose が指定できます。
c:FileUtils#options


//emlist[][ruby]{
require 'fileutils'
FileUtils.mkdir('test')
FileUtils.mkdir(%w( tmp data ))
FileUtils.mkdir('notexist', noop: true) # does not create really
//}...

Kernel.#gsub(pattern) -> Enumerator (7.0)

$_.gsub とほぼ同じですが、置換が発生したときは、$_の内容を置き換える点が異なります。 コマンドラインオプションで -p または -n を指定した時のみ定義されます。

...規表現。
文字列を指定した場合は全く同じ文字列にだけマッチする
@param replace pattern で指定した文字列と置き換える文字列

//emlist[例][ruby]{
$_ # => "test\n"
gsub(/es/, '!!') # => "t!!t\n"
//}

@see String#gsub,$_...

絞り込み条件を変える

<< < ... 3 4 5 6 > >>