252件ヒット
[1-100件を表示]
(0.123秒)
別のキーワード
ライブラリ
- ビルトイン (132)
- json (12)
-
net
/ http (24) - rake (60)
-
rexml
/ document (24)
クラス
- Array (21)
- Enumerator (24)
- Hash (14)
-
JSON
:: Parser (12) - MatchData (2)
- Module (12)
-
Net
:: HTTPResponse (12) -
REXML
:: Attributes (24) -
Rake
:: TaskArguments (60) - String (12)
- Thread (24)
- TracePoint (12)
- UncaughtThrowError (11)
モジュール
-
Net
:: HTTPExceptions (12)
キーワード
- [] (24)
- byteend (2)
-
const
_ set (12) - each (12)
-
each
_ attribute (12) - names (12)
-
new
_ scope (12) -
next
_ values (12) - pack (21)
- parse (12)
-
peek
_ values (12) - response (12)
-
return
_ value (12) -
thread
_ variable _ set (12) -
to
_ h (14) -
to
_ hash (12) - unpack (12)
-
with
_ defaults (12)
検索結果
先頭5件
-
UncaughtThrowError
# value -> object (21254.0) -
Kernel.#throw に指定した value を返します。
...Kernel.#throw に指定した value を返します。
//emlist[例][ruby]{
def do_complicated_things
throw :uncaught_label, "uncaught_value"
end
begin
do_complicated_things
rescue UncaughtThrowError => ex
p ex.value # => "uncaught_value"
end
//}... -
Net
:: HTTPResponse # value -> nil (21132.0) -
レスポンスが 2xx(成功)でなかった場合に、対応する 例外を発生させます。
...ます。
@raise HTTPError レスポンスが 1xx であるか、 net/http が知らない
種類のレスポンスである場合に発生します。
@raise HTTPRetriableError レスポンスが 3xx である場合に発生します。
@raise HTTPServerException レスポンス......。
@raise HTTPFatalError レスポンスが 5xx である場合に発生します。
//emlist[例 レスポンスが 2xx(成功)][ruby]{
require 'net/http'
uri = "http://www.example.com/index.html"
response = Net::HTTP.get_response(URI.parse(uri))
response.value # => nil
//}
//emlist[例 レス......ポンスが 2xx以外][ruby]{
require 'net/http'
uri = "http://www.example.com/invalid.html"
response = Net::HTTP.get_response(URI.parse(uri))
begin
response.value
rescue => e
e.class # => Net::HTTPServerException
e.message # => 404 "Not Found"
end
//}... -
MatchData
# byteend(n) -> Integer | nil (12349.0) -
n 番目の部分文字列終端のバイトオフセットを返します。
...ist[例][ruby]{
/(c).*(いう).*(e.*)/ =~ 'abcあいうdef'
p $~ # => #<MatchData "cあいうdef" 1:"c" 2:"いう" 3:"ef">
p $~.byteend(0) # => 15
p $~.byteend(1) # => 3
p $~.byteend(2) # => 12
p $~.byteend(3) # => 15
p $~.byteend(4) # => index 4 out of matches (IndexError)
//}
//emlist[......シンボルを指定する例][ruby]{
/(?<key>\S+):\s*(?<value>\S+)/ =~ "name: ruby"
$~ # => #<MatchData "name: ruby" key:"name" value:"ruby">
$~.byteend(:key) # => 4
$~.byteend(:value) # => 10
$~.byteend(:foo) # => undefined group name reference: foo (IndexError)
//}... -
MatchData
# byteend(name) -> Integer | nil (12349.0) -
n 番目の部分文字列終端のバイトオフセットを返します。
...ist[例][ruby]{
/(c).*(いう).*(e.*)/ =~ 'abcあいうdef'
p $~ # => #<MatchData "cあいうdef" 1:"c" 2:"いう" 3:"ef">
p $~.byteend(0) # => 15
p $~.byteend(1) # => 3
p $~.byteend(2) # => 12
p $~.byteend(3) # => 15
p $~.byteend(4) # => index 4 out of matches (IndexError)
//}
//emlist[......シンボルを指定する例][ruby]{
/(?<key>\S+):\s*(?<value>\S+)/ =~ "name: ruby"
$~ # => #<MatchData "name: ruby" key:"name" value:"ruby">
$~.byteend(:key) # => 4
$~.byteend(:value) # => 10
$~.byteend(:foo) # => undefined group name reference: foo (IndexError)
//}... -
TracePoint
# return _ value -> object (12226.0) -
メソッドやブロックの戻り値を返します。
...@raise RuntimeError :return、:c_return、:b_return イベントのためのイベ
ントフックの外側で実行した場合に発生します。
//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:return) do |tp|
p tp.return_value # => 1
end
trace.enable... -
Enumerator
# next _ values -> Array (12213.0) -
「次」のオブジェクトを配列で返します。
...トを配列で返します。
Enumerator#next とほぼ同様の挙動をします。終端まで到達した場合は
StopIteration 例外を発生させます。
このメソッドは、
yield
と
yield nil
を区別するために使えます。
next メソッドによる外部列挙の....../emlist[例: next と next_values の違いを][ruby]{
o = Object.new
def o.each
yield
yield 1
yield 1, 2
yield nil
yield [1, 2]
end
e = o.to_enum
p e.next_values
p e.next_values
p e.next_values
p e.next_values
p e.next_values
e = o.to_enum
p e.next
p e.next
p e.next
p e.next
p e.next
##......yield args next_values next
# yield [] nil
# yield 1 [1] 1
# yield 1, 2 [1, 2] [1, 2]
# yield nil [nil] nil
# yield [1, 2] [[1, 2]] [1, 2]
//}
@raise StopIteration 列挙状態が既に最... -
Thread
# thread _ variable _ set(key , value) (9230.0) -
引数 key で指定した名前のスレッドローカル変数に引数 value をセットしま す。
... value をセットしま
す。
[注意]: Thread#[] でセットしたローカル変数(Fiber ローカル変数)と
異なり、セットした変数は Fiber を切り替えても共通で使える事に注意してく
ださい。
//emlist[例][ruby]{
thr = Thread.new do
Thread.current.thr......ead_variable_set(:cat, 'meow')
Thread.current.thread_variable_set("dog", 'woof')
end
thr.join # => #<Thread:0x401b3f10 dead>
thr.thread_variables # => [:dog, :cat]
//}
@see Thread#thread_variable_get, Thread#[]... -
REXML
:: Attributes # each _ attribute {|attribute| . . . } -> () (9219.0) -
各属性に対しブロックを呼び出します。
...ML::Attribute オブジェクトで渡されます。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<root xmlns:foo="http://example.org/foo"
xmlns:bar="http://example.org/bar">
<a foo:att='1' bar:att='2' att='<'/>
</root>
EOS
a = doc.get_elements("/root/a").......first
a.attributes.each_attribute do |attr|
p [attr.namespace, attr.name, attr.value]
end
# => ["http://example.org/foo", "att", "1"]
# => ["http://example.org/bar", "att", "2"]
# => ["", "att", "<"]
//}... -
Enumerator
# peek _ values -> Array (9113.0) -
Enumerator#next_values のように「次」のオブジェクトを 配列で返しますが、列挙状態を変化させません。
...Enumerator#next_values のように「次」のオブジェクトを
配列で返しますが、列挙状態を変化させません。
Enumerator#next, Enumerator#next_values のように
現在までの列挙状態に応じて「次」のオブジェクトを返しますが、
next と異なり......、StopIteration 例外を発生します。
このメソッドは Enumerator#next_values と同様
yield
と
yield nil
を区別するために使えます。
//emlist[例][ruby]{
o = Object.new
def o.each
yield
yield 1
yield 1, 2
end
e = o.to_enum
p e.peek_values #=> []
e.next
p e.p......eek_values #=> [1]
p e.peek_values #=> [1]
e.next
p e.peek_values #=> [1, 2]
e.next
p e.peek_values # raises StopIteration
//}
@raise StopIteration 列挙状態が既に最後へ到達しているとき
@see Enumerator#next, Enumerator#next_values, Enumerator#peek_values... -
Module
# const _ set(name , value) -> object (6252.0) -
モジュールに name で指定された名前の定数を value とい う値として定義し、value を返します。
...を value とい
う値として定義し、value を返します。
そのモジュールにおいてすでにその名前の定数が定義されている場合、警
告メッセージが出力されます。
@param name Symbol,String で定数の名前を指定します。
@param value セッ......ます。
//emlist[例][ruby]{
module Foo; end
# Symbolを指定した場合
Foo.const_set(:FOO, 123)
Foo::FOO # => 123
# Stringを指定した場合
Foo.const_set('BAR', 'abc')
Foo::BAR # => "abc"
# 既に定義されている定数の名前を指定した場合
Foo.const_set('BAR', '123')
# wa......rning: already initialized constant Foo::BAR
# warning: previous definition of BAR was here
# => "123"
# 不適切な定数名を指定した場合
Foo.const_set('foo', 1) # => NameError: wrong constant name foo
//}... -
Hash
# to _ h {|key , value| block } -> Hash (6232.0) -
self を返します。Hash クラスのサブクラスから呼び出した場合は self を Hash オブジェクトに変換します。
...h オブジェクトに変換します。
//emlist[例][ruby]{
hash = {}
p hash.to_h # => {}
p hash.to_h == hash # => true
class MyHash < Hash;end
my_hash = MyHash.new
p my_hash.to_h # => {}
p my_hash.class # => MyHash
p my_hash.to_h.class # => Hash
//}
ブロックを指定す......ると各ペアでブロックを呼び出し、
その結果をペアとして使います。
//emlist[ブロック付きの例][ruby]{
hash = { "a" => 97, "b" => 98 }
hash.to_h {|key, value| [key.upcase, value-32] } # => {"A"=>65, "B"=>66}
//}
@see Enumerable#map...