るりまサーチ

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

別のキーワード

  1. date month
  2. date prev_month
  3. date next_month
  4. time month
  5. _builtin month

ライブラリ

クラス

キーワード

検索結果

<< 1 2 > >>

Time#month -> Integer (15108.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
//}...

Date#month -> Integer (15102.0)

月を返します (1-12)。

月を返します (1-12)。

Date#next_month(n = 1) -> Date (6102.0)

n ヶ月後を返します。

n ヶ月後を返します。

Date#>> も参照してください。

@param n 月数

Date#prev_month(n = 1) -> Date (6102.0)

n ヶ月前を返します。

n ヶ月前を返します。

Date#<< も参照してください。

@param n 月数

Exception#==(other) -> bool (55.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] (43.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] (19.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] (19.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 (8.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
//}...

Date#<<(n) -> Date (7.0)

self より n ヶ月前の日付オブジェクトを返します。 n は数値でなければなりません。

...せん。

//emlist[][ruby]{
require 'date'
Date.new(2001,3,31) << 2 #=> #<Date: 2001-01-31 ...>
Date.new(2001,3,31) << 1 << 1 #=> #<Date: 2001-01-28 ...>

Date.new(2001,3,31) << 1 << -1 #=> #<Date: 2001-03-28 ...>
//}

Date#prev_month も参照してください。

@param n 月数...

絞り込み条件を変える

<< 1 2 > >>