るりまサーチ

最速Rubyリファレンスマニュアル検索!
478件ヒット [101-200件を表示] (0.148秒)

別のキーワード

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

ライブラリ

モジュール

キーワード

検索結果

<< < 1 2 3 4 ... > >>

MatchData#offset(name) -> [Integer, Integer] | [nil, nil] (6165.0)

name という名前付きグループに対応する部分文字列のオフセットの配列 [start, end] を返 します。

...トの配列 [start, end] を返
します。

//emlist[例][ruby]{
[ self.begin(name), self.end(name) ]
//}

と同じです。nameの名前付きグループにマッチした部分文字列がなければ
[nil, nil] を返します。

@
param name 名前(シンボルか文字列)

@
raise IndexErr...
...emlist[例][ruby]{
/(?<year>\d{4})年(?<month>\d{1,2})月(?:(?<day>\d{1,2})日)?/ =~ "2021年1月"
p $~.offset('year') # => [0, 4]
p $~.offset(:year) # => [0, 4]
p $~.offset('month') # => [5, 6]
p $~.offset(:month) # => [5, 6]
p $~.offset('day') # => [nil, nil]
p $~.offset('century')...
...# => `offset': undefined group name reference: century (IndexError)
//}

@
see MatchData#begin, MatchData#end...
...# => `offset': undefined group name reference: century (IndexError)
//}

@
see MatchData#begin, MatchData#end, MatchData#offset...

GC#garbage_collect(full_mark: true, immediate_sweep: true) -> nil (6155.0)

ガーベージコレクトを開始します。

...GC.start や ObjectSpace.#garbage_collect と同じ働きをします。
GC.disable により GC が禁止されている場合は何もしません。

nil を返します。

@
param full_mark マイナー GC を動作させる場合は false を、そうでない場
合は true...
...を指定します。

@
param immediate_sweep sweep を遅らせる(Lazy Sweep を行う)場合は false
を、そうでない場合は true を指定します。

注意: これらのキーワード引数は Ruby の実装やバージョンによって異なりま
す。将...
...来のバージョンとの互換性も保証されません。また、Ruby の実装がサポー
トしていない場合はキーワード引数を指定しても無視される可能性があります。

//emlist[例][ruby]{
include GC
GC.count # => 3
garbage_collect
GC.count # => 4
//}...
...ベージコレクトを開始します。

GC.start や ObjectSpace.#garbage_collect と同じ働きをします。
GC.disable により GC が禁止されている場合でもガベージコレクトを開始します。

nil を返します。

@
param full_mark マイナー GC を動作させる...
...
合は true を指定します。

@
param immediate_sweep sweep を遅らせる(Lazy Sweep を行う)場合は false
を、そうでない場合は true を指定します。

注意: これらのキーワード引数は Ruby の実装やバージョンに...
...将来のバージョンとの互換性も保証されません。また、Ruby の実装がサポー
トしていない場合はキーワード引数を指定しても無視される可能性があります。

//emlist[例][ruby]{
include GC
GC.count # => 3
garbage_collect
GC.count # => 4
//}...

MatchData#offset(n) -> [Integer, Integer] | [nil, nil] (6155.0)

n 番目の部分文字列のオフセットの配列 [start, end] を返 します。

...オフセットの配列 [start, end] を返
します。

//emlist[例][ruby]{
[ self.begin(n), self.end(n) ]
//}

と同じです。n番目の部分文字列がマッチしていなければ
[nil, nil] を返します。

@
param n 部分文字列を指定する数値

@
raise IndexError 範囲外...
...の n を指定した場合に発生します。

@
see MatchData#begin, MatchData#end...
...の n を指定した場合に発生します。

@
see MatchData#begin, MatchData#end, MatchData#offset...

String#delete_prefix!(prefix) -> self | nil (6149.0)

self の先頭から破壊的に prefix を削除します。

...

@
param prefix 先頭から削除する文字列を指定します。

@
return 削除した場合は self、変化しなかった場合は nil

//emlist[][ruby]{
"hello".delete_prefix!("hel") # => "lo"
"hello".delete_prefix!("llo") # => nil
//}

@
see String#delete_prefix
@
see String#delete_suffi...
...x!
@see String#start_with?...

String#delete_prefix(prefix) -> String (6149.0)

文字列の先頭から prefix を削除した文字列のコピーを返します。

...

@
param prefix 先頭から削除する文字列を指定します。

@
return 文字列の先頭から prefix を削除した文字列のコピー

//emlist[][ruby]{
"hello".delete_prefix("hel") # => "lo"
"hello".delete_prefix("llo") # => "hello"
//}

@
see String#delete_prefix!
@
see String#delete_...
...suffix
@
see String#start_with?...

絞り込み条件を変える

Thread::SizedQueue#shift(non_block = false) -> object (6149.0)

キューからひとつ値を取り出します。 キューに push しようと待っているスレッドがあれば、実行を再開させます。

...ば、実行を再開させます。

@
param non_block true を与えると、キューが空の時に例外 ThreadError が発生します。

//emlist[例][ruby]{
require 'thread'

q = SizedQueue.new(4)

t
h1 = Thread.start do
while resource = q.pop
puts resource
end
end

[:resource1, :reso...
...ush(r)
}

t
h1.join
# => resource1
# resource2
# resource3
//}

//emlist[例: nonblock = true][ruby]{
require 'thread'

q = SizedQueue.new(4)

t
h1 = Thread.start do
while resource = q.pop
puts resource
end
end

[:resource1, :resource2, :resource3, nil].each{|r|
q.push(r)
}

begin
t
h1.join...
...q.pop(true)
rescue => e
p e
p e.message
end

# => resource1
# resource2
# resource3
# => #<ThreadError: queue empty>
# => "queue empty"
//}

@
see Thread::Queue#pop...

Thread::Queue#shift(non_block = false) -> object (6143.0)

キューからひとつ値を取り出します。キューが空の時、呼出元のスレッドは停止します。

...出元のスレッドは停止します。

@
param non_block true を与えると、キューが空の時に例外 ThreadError が発生します。

//emlist[例][ruby]{
require 'thread'

q = Queue.new

t
h1 = Thread.start do
while resource = q.pop
puts resource
end
end

[:resource1, :resour...
...ch { |r|
q.push(r)
}

t
h1.join
//}

//emlist[例: nonblock = true][ruby]{
require 'thread'

q = Queue.new

t
h1 = Thread.start do
while resource = q.pop
puts resource
end
end

[:resource1, :resource2, :resource3, nil].each { |r|
q.push(r)
}

begin
t
h1.join
q.pop(true)
rescue => e
p...
...e
end

# => resource1
# resource2
# resource3
# => #<ThreadError: queue empty>
# => "queue empty"
//}...

Net::HTTP#local_port=(port) (6137.0)

接続に用いるローカルポートを設定します。

...

@
param port ローカルポート(数値、もしくはサービス名文字列)

//emlist[例][ruby]{
require 'net/http'

http = Net::HTTP.new("www.example.com")
http.local_host = "192.168.0.5"
http.local_port = "53043"

http.start do |h|
p h.get("/").body
end
//}

@
see Net::HTTP#local_port=, N...
...et::HTTP#local_host


@
see Net::HTTP.new...

String#end_with?(*strs) -> bool (6137.0)

self の末尾が strs のいずれかであるとき true を返します。

...strs のいずれかであるとき true を返します。

@
param strs パターンを表す文字列 (のリスト)

//emlist[例][ruby]{
"string".end_with?("ing") # => true
"string".end_with?("str") # => false
"string".end_with?("str", "ing") # => true
//}

@
see String#sta...
...rt_with?
@
see String#delete_suffix, String#delete_suffix!...

Symbol#end_with?(*suffixes) -> bool (6137.0)

self の末尾が suffixes のいずれかであるとき true を返します。

...とき true を返します。

(self.to_s.end_with?と同じです。)

@
param suffixes パターンを表す文字列 (のリスト)

@
see Symbol#start_with?

@
see String#end_with?

//emlist[][ruby]{
:hello.end_with?("ello") #=> true

# returns true if one of the +suffixes+ matches....
...:hello.end_with?("heaven", "ello") #=> true
:hello.end_with?("heaven", "paradise") #=> false
//}...

絞り込み条件を変える

Net::HTTP#local_host=(host) (6131.0)

接続に用いるローカルホスト名を指定します。

...

@
param host ホスト名、もしくはアドレスを示す文字列

//emlist[例][ruby]{
require 'net/http'

http = Net::HTTP.new("www.example.com")
http.local_host = "192.168.0.5"
http.local_port = "53043"

http.start do |h|
p h.get("/").body
end
//}

@
see Net::HTTP#local_host=, Net::HTTP#lo...
...cal_port...
<< < 1 2 3 4 ... > >>