るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

キーワード

検索結果

<< 1 2 3 > >>

Time#month -> Integer (15107.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 (15101.0)

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

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

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

n ヶ月後を返します。

n ヶ月後を返します。

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

@param n 月数

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

n ヶ月前を返します。

n ヶ月前を返します。

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

@param n 月数

CGI::RFC822_MONTHS -> [String] (6100.0)

822 で定義されている月名の略称を返します。

822 で定義されている月名の略称を返します。

@see 822

絞り込み条件を変える

Date#deconstruct_keys(array_of_names_or_nil) -> Hash (54.0)

パターンマッチに使用する名前と値の Hash を返します。

...ターンマッチに使用する名前と値の Hash を返します。

キーに利用できる名前は以下の通りです。

* :year
* :month
* :day
* :yday
* :wday

@param array_of_names_or_nil パターンマッチに使用する名前の配列を指定します。nil の場合...
...
puts "first Wednesday of the month"
end
#=> "first Wednesday of the month" が出力される

case d
in year: ...2022
puts "too old"
in month: ..9
puts "quarter 1-3"
in wday: 1..5, month:
puts "working day in month #{month}"
end
#=> "working day in month 10" が出力される

# クラ...
...スのチェックと組み合わせて利用することもできます
if d in Date(wday: 3, day: ..7)
puts "first Wednesday of the month"
end
//}

@see d:spec/pattern_matching#matching_non_primitive_objects...

Exception#==(other) -> bool (54.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 が同一だ...

Time#deconstruct_keys(array_of_names_or_nil) -> Hash (54.0)

パターンマッチに使用する名前と値の Hash を返します。

...ターンマッチに使用する名前と値の Hash を返します。

キーに利用できる名前は以下の通りです。

* :year
* :month
* :day
* :yday
* :wday
* :hour
* :min
* :sec
* :subsec
* :dst
* :zone

@param array_of_names_or_nil パターンマッチに使...
...
puts "first Wednesday of the month"
end
#=> "first Wednesday of the month" が出力される

case t
in year: ...2022
puts "too old"
in month: ..9
puts "quarter 1-3"
in wday: 1..5, month:
puts "working day in month #{month}"
end
#=> "working day in month 10" が出力される

# クラ...
...スのチェックと組み合わせて利用することもできます
if t in Time(wday: 3, day: ..7)
puts "first Wednesday of the month"
end
//}

@see d:spec/pattern_matching#matching_non_primitive_objects...

DateTime#deconstruct_keys(array_of_names_or_nil) -> Hash (42.0)

パターンマッチに使用する名前と値の Hash を返します。

...ターンマッチに使用する名前と値の Hash を返します。

キーに利用できる名前は以下の通りです。

* :year
* :month
* :day
* :yday
* :wday
* :hour
* :min
* :sec
* :sec_fraction
* :zone

@param array_of_names_or_nil パターンマッチに使用...
..."
end
#=> "Working time" が出力される

case dt
in year: ...2022
puts "too old"
in month: ..9
puts "quarter 1-3"
in wday: 1..5, month:
puts "working day in month #{month}"
end
#=> "working day in month 10" が出力される

# クラスのチェックと組み合わせて利用するこ...
...ともできます
if dt in DateTime(wday: 1..5, hour: 10..18, day: ..7)
puts "Working time, first week of the month"
end
//}

@see d:spec/pattern_matching#matching_non_primitive_objects...

Exception#backtrace_locations -> [Thread::Backtrace::Location] (42.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] (18.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] (18.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 $...
<< 1 2 3 > >>