るりまサーチ

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

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

モジュール

キーワード

検索結果

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

Kernel.#chomp(rs = $/) -> String (156.0)

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

...//emlist[例: ruby -n で "test" を入力][ruby]{
$_ # => "test\n"
chomp # => "test"
//}

//emlist[例: ruby -n で "test," を入力し、 rs に "," を指定][ruby]{
$_ # => "test\n"
chomp # => "test,"
chomp(",") # => "test"
//}

@see String#chomp,$_,$/...

JSON.#pretty_generate(object, options = nil) -> String (147.0)

Ruby のオブジェクトを JSON 形式の文字列に変換して返します。

...
Ruby
のオブジェクトを JSON 形式の文字列に変換して返します。

このメソッドは JSON.#generate よりも人間に読みやすい文字列を返します。

pretty_unparse は将来削除される予定です。

@param object JSON 形式の文字列に変換するオブ...
...きます。
ハッシュを使用する場合指定可能なオプションは JSON.#generate を参照してください。

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

hash = { "name": "tanaka", "age": 19 }
puts JSON.generate(hash)
# => {"name":"tanaka","age":19}

puts JSON.pretty_generate(hash)...

JSON.#pretty_unparse(object, options = nil) -> String (147.0)

Ruby のオブジェクトを JSON 形式の文字列に変換して返します。

...
Ruby
のオブジェクトを JSON 形式の文字列に変換して返します。

このメソッドは JSON.#generate よりも人間に読みやすい文字列を返します。

pretty_unparse は将来削除される予定です。

@param object JSON 形式の文字列に変換するオブ...
...きます。
ハッシュを使用する場合指定可能なオプションは JSON.#generate を参照してください。

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

hash = { "name": "tanaka", "age": 19 }
puts JSON.generate(hash)
# => {"name":"tanaka","age":19}

puts JSON.pretty_generate(hash)...

Process.#argv0 -> String (146.0)

現在実行中の Ruby スクリプトの名前を表す文字列です。$0 を更新して も本メソッドの戻り値への影響はありません。

...現在実行中の Ruby スクリプトの名前を表す文字列です。$0 を更新して
も本メソッドの戻り値への影響はありません。

本メソッドは 2.1 以降でグローバル変数を用いないで現在実行中の Ruby スク
リプトの名前を表す文字列...

Process.#setproctitle(title) -> String (146.0)

ps(1) が出力する現在実行中の Ruby スクリプトの名前を引数 title で指定した文字列に変更します。

...ps(1) が出力する現在実行中の Ruby スクリプトの名前を引数 title
で指定した文字列に変更します。

OS によっては何も行われません。また、処理結果に関係なく例外は発生しませ
ん。サポートされる OS ではない場合であって...
...
りません。

Process.setproctitle('myapp: worker #%d' % worker_id)

本メソッドは 2.1 以降でグローバル変数を用いないで現在実行中の Ruby スク
リプトの名前を表す文字列を設定する手段として提供されました。

@see Process.#argv0, $0...

絞り込み条件を変える

Kernel.#caller(range) -> [String] | nil (140.0)

start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。

...囲を示す Range オブジェクトを指定します。

@see Kernel.#set_trace_func,Kernel.#raise,
Kernel.#caller_locations

//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end

def bar
foo
end

bar

#=> ["-:2:in `foo'", "-:10:in `bar'",...
...nil
//}

以下の関数は、caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。

//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]
end
end...
...=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}

以下は、$DEBUG が真の場合に役に立つ debug 関数
のサンプルです。

//emlist[例][ruby]{
$DEBUG = true

def debug(*args)
p [caller.first, *args] if $DEBUG
end

debug "debug information"

#=> ["-:7", "debug information"]
//}...

Kernel.#caller(start = 1) -> [String] | nil (140.0)

start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。

...囲を示す Range オブジェクトを指定します。

@see Kernel.#set_trace_func,Kernel.#raise,
Kernel.#caller_locations

//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end

def bar
foo
end

bar

#=> ["-:2:in `foo'", "-:10:in `bar'",...
...nil
//}

以下の関数は、caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。

//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]
end
end...
...=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}

以下は、$DEBUG が真の場合に役に立つ debug 関数
のサンプルです。

//emlist[例][ruby]{
$DEBUG = true

def debug(*args)
p [caller.first, *args] if $DEBUG
end

debug "debug information"

#=> ["-:7", "debug information"]
//}...

Kernel.#caller(start, length) -> [String] | nil (140.0)

start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。

...囲を示す Range オブジェクトを指定します。

@see Kernel.#set_trace_func,Kernel.#raise,
Kernel.#caller_locations

//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end

def bar
foo
end

bar

#=> ["-:2:in `foo'", "-:10:in `bar'",...
...nil
//}

以下の関数は、caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。

//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]
end
end...
...=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}

以下は、$DEBUG が真の場合に役に立つ debug 関数
のサンプルです。

//emlist[例][ruby]{
$DEBUG = true

def debug(*args)
p [caller.first, *args] if $DEBUG
end

debug "debug information"

#=> ["-:7", "debug information"]
//}...

ERB::Util.#u(s) -> String (139.0)

文字列 s を URLエンコードした文字列を返します。

...を返します(CGI.escapeとほぼ同じです)。

@param s URLエンコードを行う文字列

//emlist[例][ruby]{
require "erb"
include ERB::Util

puts url_encode("Programming Ruby: The Pragmatic Programmer's Guide")
# Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide
//}...
<< < ... 3 4 5 6 7 ... > >>