別のキーワード
クラス
- Array (44)
-
Encoding
:: Converter (11) -
Enumerator
:: Lazy (22) - Exception (7)
- Range (33)
- Regexp (11)
-
RubyVM
:: AbstractSyntaxTree :: Node (12) - String (154)
- Thread (8)
モジュール
- Enumerable (66)
キーワード
- =~ (11)
- [] (66)
- begin (11)
-
chunk
_ while (11) - first (44)
-
last
_ column (6) -
last
_ error (11) -
last
_ lineno (6) -
report
_ on _ exception (8) - slice (66)
- slice! (22)
-
slice
_ after (22) -
slice
_ before (22) -
slice
_ when (11) - zip (22)
検索結果
先頭5件
-
Array
# last(n) -> Array (18269.0) -
末尾の n 要素を配列で返します。n は 0 以上でなければなりません。
...上でなければなりません。
@param n 取得したい要素の個数を整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引数に整数以外の(暗黙......指定した場合に発生します。
@raise ArgumentError n が負値の場合発生します。
//emlist[例][ruby]{
ary = [0, 1, 2]
p ary.last(0)
p ary.last(1)
p ary.last(2)
p ary.last(3)
p ary.last(4)
# => []
# [2]
# [1, 2]
# [0, 1, 2]
# [0, 1, 2]
//}
@see Array#first... -
Array
# last -> object | nil (18239.0) -
配列の末尾の要素を返します。配列が空のときは nil を返します。
...配列の末尾の要素を返します。配列が空のときは nil を返します。
//emlist[例][ruby]{
p [0, 1, 2].last #=> 2
p [].last #=> nil
//}
@see Array#first... -
Encoding
:: Converter # last _ error -> Exception | nil (6364.0) -
直前に変換器で発生した例外に相当する例外オブジェクトを返します。 直前の変換で例外が発生していない場合は nil を返します。
...ew("utf-8", "iso-8859-1")
p ec.primitive_convert(src="\xf1abcd", dst="") #=> :invalid_byte_sequence
p ec.last_error #=> #<Encoding::InvalidByteSequenceError: "\xF1" followed by "a" on UTF-8>
p ec.primitive_convert(src, dst, nil, 1) #=> :destination_buffer_full
p ec.last_error... -
RubyVM
:: AbstractSyntaxTree :: Node # last _ column -> Integer (6222.0) -
ソースコード中で、self を表すテキストが最後に現れる列番号を返します。
...ソースコード中で、self を表すテキストが最後に現れる列番号を返します。
列番号は0-originで、バイト単位で表されます。
//emlist[][ruby]{
node = RubyVM::AbstractSyntaxTree.parse('1 + 1')
p node.last_column # => 5
//}... -
RubyVM
:: AbstractSyntaxTree :: Node # last _ lineno -> Integer (6222.0) -
ソースコード中で、self を表すテキストが最後に現れる行番号を返します。
...ソースコード中で、self を表すテキストが最後に現れる行番号を返します。
行番号は1-originです。
//emlist[][ruby]{
node = RubyVM::AbstractSyntaxTree.parse('1 + 1')
p node.last_lineno # => 1
//}... -
Enumerator
:: Lazy # zip(*lists) -> Enumerator :: Lazy (6209.0) -
Enumerable#zip と同じですが、配列ではなくEnumerator::Lazy を返します。
...Enumerable#zip と同じですが、配列ではなくEnumerator::Lazy を返します。
ただし一貫性のため、ブロック付きで呼び出した場合は Enumerable#zip と
同じ挙動になります。
//emlist[例][ruby]{
1.step.lazy.zip(('a'..'z').cycle)
# => #<Enumerator::Lazy: #......<Enumerator::Lazy: #<Enumerator: 1:step>>:zip(#<Enumerator: "a".."z":cycle>)>
1.step.lazy.zip(('a'..'z').cycle).take(30).force.last(6)
# => [[25, "y"], [26, "z"], [27, "a"], [28, "b"], [29, "c"], [30, "d"]]
//}
@see Enumerable#zip... -
Enumerator
:: Lazy # zip(*lists) {|v1 , v2 , . . . | . . . } -> nil (6209.0) -
Enumerable#zip と同じですが、配列ではなくEnumerator::Lazy を返します。
...Enumerable#zip と同じですが、配列ではなくEnumerator::Lazy を返します。
ただし一貫性のため、ブロック付きで呼び出した場合は Enumerable#zip と
同じ挙動になります。
//emlist[例][ruby]{
1.step.lazy.zip(('a'..'z').cycle)
# => #<Enumerator::Lazy: #......<Enumerator::Lazy: #<Enumerator: 1:step>>:zip(#<Enumerator: "a".."z":cycle>)>
1.step.lazy.zip(('a'..'z').cycle).take(30).force.last(6)
# => [[25, "y"], [26, "z"], [27, "a"], [28, "b"], [29, "c"], [30, "d"]]
//}
@see Enumerable#zip... -
Thread
# report _ on _ exception -> bool (6209.0) -
真の場合、そのスレッドが例外によって終了した時に、その内容を $stderr に報告します。
...Thread.report_on_exception です。
@param newstate スレッド実行中に例外発生した場合、その内容を報告するかどうかを true か false で指定します。
//emlist[例][ruby]{
a = Thread.new{ Thread.stop; raise }
a.report_on_exception = true
a.report_on_exception #......rb):1 run> terminated with exception (report_on_exception is true):
# Traceback (most recent call last):
# (irb):1:in `block in irb_binding': unhandled exception
# #<Thread:0x00007fc3f48c7908@(irb):1 dead>
b = Thread.new{ Thread.stop; raise }
b.report_on_exception = false
b.run # => #<Thr......ead:0x00007fc3f48aefc0@(irb):4 dead>
//}
@see Thread.report_on_exception... -
Regexp
# =~(string) -> Integer | nil (3163.0) -
文字列 string との正規表現マッチを行います。マッチした場合、 マッチした位置のインデックスを返します(先頭は0)。マッチしなかった 場合、あるいは string が nil の場合には nil を返 します。
...][ruby]{
p /foo/ =~ "foo" # => 0
p /foo/ =~ "afoo" # => 1
p /foo/ =~ "bar" # => nil
//}
組み込み変数 $~ もしくは Regexp.last_match にマッチに関する情報 MatchData が設定されます。
文字列のかわりにSymbolをマッチさせることができます。
@param strin......@raise TypeError string が nil でも String オブジェクト
でも Symbol でもない場合発生します。
//emlist[例][ruby]{
p /foo/ =~ "foo" # => 0
p Regexp.last_match(0) # => "foo"
p /foo/ =~ "afoo" # => 1
p $~[0] # => "foo"
p /foo/ =~......"bar" # => nil
unless /foo/ === "bar"
puts "not match " # => not match
end
str = []
begin
/ugo/ =~ str
rescue TypeError
printf "! %s\t%s\n", $!, $@ # => ! can't convert Array into String r5.rb:15
end
//}... -
Exception
# full _ message(highlight: true , order: :bottom) -> String (3133.0) -
例外の整形された文字列を返します。
...は 2.5.1 で追加されました。
@param highlight エスケープシーケンスによる文字装飾をつけるかどうかを指定します。
デフォルト値は Exception.to_tty? の返り値と同じです。
@param order :top か :bottom で指定する必要があ......ージの上(top)か下(bottom)かを指定します。
デフォルト値は Exception.to_tty? が真なら :bottom で偽なら :top です。
//emlist[例][ruby]{
begin
raise "test"
rescue => e
p e.full_message # => "\e[1mTraceback \e[m(most recent call last):\ntest.rb:2:in `<......e[1m)\n\e[m"
$stderr = $stdout
p e.full_message # => "test.rb:2:in `<main>': test (RuntimeError)\n"
$stderr = STDERR
p e.full_message # => "\e[1mTraceback \e[m(most recent call last):\ntest.rb:2:in `<main>': \e[1mtest (\e[4;1mRuntimeError\e[m\e[1m)\n\e[m"
end
//}
@see Exception.to_tty?......文字装飾がついています。
@param highlight エスケープシーケンスによる文字装飾をつけるかどうかを指定します。
デフォルト値は Exception.to_tty? の返り値と同じです。
@param order :top か :bottom で指定する必要があ... -
String
# [](regexp , name) -> String (280.0) -
正規表現 regexp の name で指定した名前付きキャプチャにマッチする最初の 部分文字列を返します。正規表現が self にマッチしなかった場合は nil を返 します。
...正規表現 regexp の name で指定した名前付きキャプチャにマッチする最初の
部分文字列を返します。正規表現が self にマッチしなかった場合は nil を返
します。
@param regexp 正規表現を指定します。
@param name 取得したい部分文......ない場合に発生します。
//emlist[例][ruby]{
s = "FooBar"
s[/(?<foo>[A-Z]..)(?<bar>[A-Z]..)/] # => "FooBar"
s[/(?<foo>[A-Z]..)(?<bar>[A-Z]..)/, "foo"] # => "Foo"
s[/(?<foo>[A-Z]..)(?<bar>[A-Z]..)/, "bar"] # => "Bar"
s[/(?<foo>[A-Z]..)(?<bar>[A-Z]..)/, "baz"] # => IndexError
//}...