るりまサーチ

最速Rubyリファレンスマニュアル検索!
602件ヒット [1-100件を表示] (0.061秒)

別のキーワード

  1. _builtin begin
  2. range begin
  3. matchdata begin
  4. arithmeticsequence begin
  5. begin

検索結果

<< 1 2 3 ... > >>

MatchData#begin(n) -> Integer | nil (24137.0)

n 番目の部分文字列先頭のオフセットを返します。

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

//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.begin(0) # => 0
p $~.begin(1) # => 0
p $~.begin(2) # => 3
p $~.begin(3) # => nil
p $~.begin(4) # => `begin': index 4 out of matches (IndexError)
//}

@see MatchData#end...

Enumerator::ArithmeticSequence#begin -> Numeric (21101.0)

初項 (始端) を返します。

...初項 (始端) を返します。

@see Enumerator::ArithmeticSequence#end...

Enumerator::ArithmeticSequence#begin -> Numeric | nil (21101.0)

初項 (始端) を返します。

...初項 (始端) を返します。

@see Enumerator::ArithmeticSequence#end...

Array#at(nth) -> object | nil (15106.0)

nth 番目の要素を返します。nth 番目の要素が存在しない時には nil を返します。

nth 番目の要素を返します。nth 番目の要素が存在しない時には nil を返します。

@param nth インデックスを整数で指定します。
先頭の要素が 0 番目になります。nth の値が負の時には末尾から
のインデックスと見倣します。末尾の要素が -1 番目になります。
整数以外のオブジェクトを指定した場合は to_int メソッドによる
暗黙の型変換を試みます。

@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定...

Regexp.last_match -> MatchData (6301.0)

カレントスコープで最後に行った正規表現マッチの MatchData オ ブジェクトを返します。このメソッドの呼び出しは $~ の参照と同じです。

...MatchData オ
ブジェクトを返します。このメソッドの呼び出しは $~
の参照と同じです。

//emlist[例][ruby]{
/(.)(.)/ =~ "ab"
p Regexp.last_match # => #<MatchData:0x4599e58>
p Regexp.last_match[0] # => "ab"
p Regexp.last_match[1] # => "a"
p Regexp.last_match[2]...
...# => "b"
p Regexp.last_match[3] # => nil
//}...

絞り込み条件を変える

Exception#backtrace_locations -> [Thread::Backtrace::Location] (6206.0)

バックトレース情報を返します。Exception#backtraceに似ていますが、 Thread::Backtrace::Location の配列を返す点が異なります。

...が、
Thread::Backtrace::Location の配列を返す点が異なります。

現状では Exception#set_backtrace によって戻り値が変化する事はあり
ません。

//emlist[例: test.rb][ruby]{
require "date"
def check_long_month(month)
return if Date.new(2000, month, -1).day == 31...
...raise "#{month} is not long month"
end

def get_exception
return begin
yield
rescue => e
e
end
end

e = get_exception { check_long_month(2) }
p e.backtrace_locations
# => ["test.rb:4:in `check_long_month'", "test.rb:15:in `block in <main>'", "test.rb:9:in `get_exception'", "test.rb:1...

Time.httpdate(date) -> Time (6206.0)

2616で定義されているHTTP-dateとしてdateをパースして Timeオブジェクトに変換します。

...るHTTP-dateとしてdateをパースして
Timeオブジェクトに変換します。

dateが2616に準拠していない、または
Timeクラスが指定された日時を表現できないときにArgumentErrorが
発生します。

@param date 2616で定義されているHTTP-dateとして...
...定します。

@raise ArgumentError dateが2616に準拠していない、または Timeクラスが指定された日時を表現できないときに発生します。

require 'time'
rfc2616_time = 'Sun, 31 Aug 2008 12:34:56 GMT'

t = Time.httpdate(rfc2616_time)
p t.kind_of?(Time) #=> t...
...rue

non_rfc2616_time = 'San, 31 Aug 2008 12:34:56 GMT'
begin

Time.httpdate(non_rfc2616_time)
rescue ArgumentError => err
puts err #=> not RFC 2616 compliant date: "San, 31 Aug 2008 12:34:56 GMT"
end...

SystemExit#status -> Integer (6112.0)

例外オブジェクトに保存された終了ステータスを返します。

...します。

終了ステータスは Kernel.#exit や SystemExit.new などで設定されます。

例:

begin

exit 1
rescue SystemExit => err
p err.status # => 1
end

begin

raise SystemExit.new(1, "dummy exit")
rescue SystemExit => err
p err.status # => 1
end...

LoadError#path -> String | nil (6106.0)

Kernel.#require や Kernel.#load に失敗したパスを返します。

...Kernel.#require や Kernel.#load に失敗したパスを返します。

begin

require 'this/file/does/not/exist'
rescue LoadError => e
e.path # => 'this/file/does/not/exist'
end

パスが定まらない場合は nil を返します。...

PrettyPrint.format(output = &#39;&#39;, maxwidth = 79, newline = "\n", genspace = lambda{|n| &#39; &#39; * n}) {|pp| ...} -> object (6106.0)

PrettyPrint オブジェクトを生成し、それを引数としてブロックを実行します。 与えられた output を返します。

...t を返します。

以下と同じ働きをするもので簡便のために用意されています。

//emlist[][ruby]{
require 'prettyprint'

begin

pp = PrettyPrint.new(output, maxwidth, newline, &genspace)
...
pp.flush
output
end
//}

@param output 出力先を指定します。outpu...

絞り込み条件を変える

Regexp.last_match(nth) -> String | nil (6106.0)

整数 nth が 0 の場合、マッチした文字列を返します ($&)。それ以外では、nth 番目の括弧にマッチ した部分文字列を返します($1,$2,...)。 対応する括弧がない場合やマッチしなかった場合には nil を返し ます。

...b"
p Regexp.last_match # => #<MatchData:0x4599e58>
p Regexp.last_match(0) # => "ab"
p Regexp.last_match(1) # => "a"
p Regexp.last_match(2) # => "b"
p Regexp.last_match(3) # => nil
//}

正規表現全体がマッチしなかった場合、引数なしの
Regexp.last_match はnil を返...
...すため、
last_match[1] の形式では例外 NoMethodError が発生します。
対して、last_match(1) は nil を返します。

//emlist[例][ruby]{
str = "This is Regexp"
/That is Regexp/ =~ str
p Regexp.last_match # => nil
begin

p Regexp.last_match[1] # 例外が発生する
rescue...
...puts $! # => undefined method `[]' for nil:NilClass
end
p Regexp.last_match(1) # => nil
//}

@param nth 整数を指定します。
整数 nth が 0 の場合、マッチした文字列を返します。それ以外では、nth 番目の括弧にマッチした部分文字列を返します。...
<< 1 2 3 ... > >>