るりまサーチ

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

別のキーワード

  1. openssl p
  2. openssl p=
  3. fileutils mkdir_p
  4. dsa p
  5. dsa p=

ライブラリ

クラス

キーワード

検索結果

<< 1 2 > >>

Time#month -> Integer (15120.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#prev_month(n = 1) -> Date (12202.0)

n ヶ月前を返します。

...n ヶ月前を返します。

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

@param n 月数...

Time#httpdate -> String (6113.0)

2616 で定義されている HTTP-date の rfc1123-date 形式の文字列を 返します。

...2616 で定義されている HTTP-date の rfc1123-date 形式の文字列を
返します。

@return 以下の形式の文字列を返します。
//emlist{
day-of-week, DD month-name CCYY hh:mm:ss GMT
//}
注意: 結果はいつも UTC (GMT) です。

使用例
require 'time'

is...
...o8601_time = '2008-08-31T12:34:56+09:00'
t = Time.iso8601(iso8601_time)
p
t.httpdate #=> "Sun, 31 Aug 2008 03:34:56 GMT"...

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

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

...@param other 自身と比較したいオブジェクトを指定します。
自身と異なるクラスのオブジェクトを指定した場合は
Exception#exception を実行して変換を試みます。

//emlist[例][ruby]{
require "date"
def check_long_month(month)...
... 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...
...essage }
# => ["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 が同一だが、message がことなるため false になる
p
results[0] == results[2]...

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

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

...。Exception#backtraceに似ていますが、
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>'", "t...
...est.rb:9:in `get_exception'", "test.rb:15:in `<main>'"]
//}

@see Exception#backtrace...

絞り込み条件を変える

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

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

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

@param format フォーマット文字列を指定します。使用できるものは 以下の通りです。

* %A: 曜日の名称(Sunday, Monday ... )
* %a: 曜日の省略名(Sun, Mon ... )
* %B: 月...
...%P: 午前または午後(am,pm)
* %p: 午前または午後(AM,PM)
* %Q: 1970-01-01 00:00:00 UTC からの経過ミリ秒 (Time#strftime は対応していませんが、Date#strftime で使えます)
* %R: 24時間制の時刻。%H:%M と同等。
* %r: 12時間制の時刻。%I:%M:%S %p...
...{
p
t = Time.new(2001,2,3,4,5,6,"+09:00") # => 2001-02-03 04:05:06 +0900
p
t.strftime("Printed on %m/%d/%Y") # => "Printed on 02/03/2001"
p
t.strftime("Printed on %m/%-d/%_6Y") # => "Printed on 02/3/ 2001"
p
t.strftime("at %I:%M%p") # => "at 04:05AM"
p
t.strftime("at %I:%M%#p"...

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

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

...@param name 名前(シンボルか文字列)

@raise IndexError 正規表現中で定義されていない name を指定した場合に発生します。

//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') # => [nil, nil]
p
$~.byteoffset('century') # => `offset': undefined group name reference: century (IndexError)
//}

@see MatchData#offset...

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

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

...@param name 名前(シンボルか文字列)

@raise IndexError 正規表現中で定義されていない name を指定した場合に発生します。

//emlist[例][ruby]{
/(?<year>\d{4})年(?<month>\d{1,2})月(?:(?<day>\d{1,2})日)?/ =~ "2021年1月"
p
$~.offset('year') # => [0, 4]
p
$~.o...
...ffset(:year) # => [0, 4]
p
$~.offset('month') # => [5, 6]
p
$~.offset(:month) # => [5, 6]
p
$~.offset('day') # => [nil, nil]
p
$~.offset('century') # => `offset': undefined group name reference: century (IndexError)
//}

@see MatchData#begin, MatchData#end...
...ffset(:year) # => [0, 4]
p
$~.offset('month') # => [5, 6]
p
$~.offset(:month) # => [5, 6]
p
$~.offset('day') # => [nil, nil]
p
$~.offset('century') # => `offset': undefined group name reference: century (IndexError)
//}

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

Time#mon -> Integer (20.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#to_a -> Array (19.0)

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

...,3,4,5)
p
t # => 2000-01-02 03:04:05 +0900
p
t.to_a # => [5, 4, 3, 2, 1, 2000, 0, 2, false, "JST"]
//}

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

注意: C 言語の tm 構造体とは異なり、month は 1...

絞り込み条件を変える

<< 1 2 > >>