るりまサーチ

最速Rubyリファレンスマニュアル検索!
396件ヒット [101-200件を表示] (0.086秒)
トップページ > クエリ:string[x] > クエリ:ruby[x] > 種類:モジュール関数[x] > クエリ:String[x] > ライブラリ:ビルトイン[x]

別のキーワード

  1. string []=
  2. string slice
  3. string []
  4. string slice!
  5. string gsub!

モジュール

キーワード

検索結果

<< < 1 2 3 4 > >>

Kernel.#caller(start, length) -> [String] | nil (227.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"]
//}...

Process.#argv0 -> String (227.0)

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

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

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

Process.#setproctitle(title) -> String (227.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.#gsub(pattern) {|matched| ... } -> String (225.0)

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

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

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

@see String#gsub,$_...

Kernel.#gsub(pattern, replace) -> String (225.0)

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

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

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

@see String#gsub,$_...

絞り込み条件を変える

Kernel.#sub(pattern) {|matched| ... } -> String (225.0)

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

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

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

@see String#sub,$_...

Kernel.#sub(pattern, replace) -> String (225.0)

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

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

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

@see String#sub,$_...

Kernel.#`(command) -> String (223.0)

command を外部コマンドとして実行し、その標準出力を文字列として 返します。このメソッドは `command` の形式で呼ばれます。

...で返します。
@raise Errno::EXXX コマンドを実行できないときや失敗した場合に発生します。

//emlist[例][ruby]{
puts `ruby -v` #=> ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]
puts $?.inspect #=> #<Process::Status: pid=3580,exited(0)>
//}

@see Kernel.#system,Ker...

Kernel.#autoload?(const_name) -> String | nil (223.0)

const_name が Kernel.#autoload 設定されているか調べます。

...

autoload 設定されていないか、ロード済みなら nil を返します。

@param const_name 定数をString または Symbol で指定します。

//emlist[例][ruby]{
# ------- /tmp/foo.rb ---------
class Foo
class Bar
end
end
# ----- end of /tmp/foo.rb ----

class Foo
end
p Fo...
<< < 1 2 3 4 > >>