るりまサーチ

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

クラス

キーワード

検索結果

Time#month -> Integer (23110.0)

月を整数で返します。

...月を整数で返します。

//emlist[][ruby]{
t = Time.local(2000,1,2,3,4,5) # => 2000-01-02 03:04:05 +0900
p t.month # => 1
p t.mon # => 1
//}...

Exception#==(other) -> bool (8057.0)

自身と指定された other のクラスが同じであり、 message と backtrace が == メソッドで比較して 等しい場合に true を返します。そうでない場合に false を返します。

...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

results = [2, 2, 4].map { |e | get_exception { check_long_month(e) } }
p results.map { |e| e....
...class }
# => [RuntimeError, RuntimeError, RuntimeError]
p results.map { |e| e.message }
# => ["2 is not long month", "2 is not long month", "4 is not long month"]

# class, message, backtrace が同一のため true になる
p results[0] == results[1] # => true

# class, backtrace が同一だ...

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

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

...heck_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....

MatchData#byteoffset(name) -> [Integer, Integer] | [nil, nil] (8021.0)

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

...す。

//emlist[例][ruby]{
/(?<year>\d{4})年(?<month>\d{1,2})月(?:(?<day>\d{1,2})日)?/ =~ "2021年1月"
p $~.byteoffset('year') # => [0, 4]
p $~.byteoffset(:year) # => [0, 4]
p $~.byteoffset('month') # => [7, 8]
p $~.byteoffset(:month) # => [7, 8]
p $~.byteoffset('day') # => [ni...

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

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

...生します。

//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 $...

絞り込み条件を変える

Time#mon -> Integer (8010.0)

月を整数で返します。

...月を整数で返します。

//emlist[][ruby]{
t = Time.local(2000,1,2,3,4,5) # => 2000-01-02 03:04:05 +0900
p t.month # => 1
p t.mon # => 1
//}...

Time#strftime(format) -> String (8009.0)

時刻を format 文字列に従って文字列に変換した結果を返します。

...3 Calendar date (extended)
p t.strftime("%Y-%m") # => 2001-02 Calendar date, reduced accuracy, specific month
p t.strftime("%Y") # => 2001 Calendar date, reduced accuracy, specific year
p t.strftime("%C") #...

Time#to_a -> Array (8009.0)

時刻を10要素の配列で返します。

...C 言語の tm 構造体に合わせています。ただし、
tm 構造体に zone はありません。

注意: C 言語の tm 構造体とは異なり、month は 1 月に対
して 1 を返し、year は 1998 年に対して 1998 を返します。また、
yday は 1 から数えます。...

MatchData#byteoffset(n) -> [Integer, Integer] | [nil, nil] (8006.0)

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

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

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

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

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

@see MatchData#offset

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

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

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

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

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

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

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

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

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

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

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

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

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

絞り込み条件を変える