種類
- インスタンスメソッド (92)
- クラス (11)
キーワード
- == (11)
- Time (11)
-
backtrace
_ locations (11) - byteoffset (4)
- mon (11)
- offset (22)
- strftime (11)
-
to
_ a (11)
検索結果
先頭5件
-
Time
# month -> Integer (26209.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
# backtrace _ locations -> [Thread :: Backtrace :: Location] (17244.0) -
バックトレース情報を返します。Exception#backtraceに似ていますが、 Thread::Backtrace::Location の配列を返す点が異なります。
...ception#backtraceに似ていますが、
Thread::Backtrace::Location の配列を返す点が異なります。
現状では Exception#set_backtrace によって戻り値が変化する事はあり
ません。
//emlist[例: test.rb][ruby]{
require "date"
def check_long_month(month)
return if D......000, 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 `g......et_exception'", "test.rb:15:in `<main>'"]
//}
@see Exception#backtrace... -
Time
# strftime(format) -> String (17132.0) -
時刻を format 文字列に従って文字列に変換した結果を返します。
...角空白で埋める ( 1..31)
* %F: %Y-%m-%d と同等 (ISO 8601の日付フォーマット)
* %G: ISO 8601の暦週の年
* %g: ISO 8601の暦週の年の下2桁(00-99)
* %H: 24時間制の時(00-23)
* %h: %b と同等
* %I: 12時間制の時(01-12)
* %j: 年中の通算日(001-366)......後(AM,PM)
* %Q: 1970-01-01 00:00:00 UTC からの経過ミリ秒 (Time#strftime は対応していませんが、Date#strftime で使えます)
* %R: 24時間制の時刻。%H:%M と同等。
* %r: 12時間制の時刻。%I:%M:%S %p と同等。
* %S: 秒(00-60) (60はうるう秒)
* %s:......(\t)
* %U: 週を表す数。最初の日曜日が第1週の始まり(00-53)
* %u: 月曜日を1とした、曜日の数値表現 (1..7)
* %V: ISO 8601形式の暦週 (01..53)
* %v: VMS形式の日付 (%e-%^b-%4Y)
* %W: 週を表す数。最初の月曜日が第1週の始まり(00-53)
*... -
Time (14008.0)
-
時刻を表すクラスです。
...時刻を表すクラスです。
Time.now は現在の時刻を返します。
File.mtime などが返すファイルのタイムスタンプは Time
オブジェクトです。
Time オブジェクトは時刻を起算時からの経過秒数で保持しています。
起算時は協定世界......定するかどうかはシステムに
よります。
Time オブジェクトが格納可能な時刻の範囲は環境によって異なっていましたが、
Ruby 1.9.2 からは OS の制限の影響を受けません。
また、Time オブジェクトは協定世界時と地方時のど......mlist[][ruby]{
p Marshal.load(Marshal.dump(Time.now.gmtime)).zone
# => "UTC"
//}
time ライブラリによって、Time.parse, Time.rfc2822, Time.httpdate, Time.iso8601 等が拡張されます。
Ruby 1.9.2 以降の Time クラスのデザインの詳細は
https://staff.aist.go.jp/tanaka-akira... -
Time
# mon -> Integer (11109.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 (11056.0) -
自身と指定された other のクラスが同じであり、 message と backtrace が == メソッドで比較して 等しい場合に true を返します。そうでない場合に false を返します。
...合は
Exception#exception を実行して変換を試みます。
//emlist[例][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......d
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 が同一の... -
Time
# to _ a -> Array (11008.0) -
時刻を10要素の配列で返します。
...(整数 0-60) (60はうるう秒)
* min: 分 (整数 0-59)
* hour: 時 (整数 0-23)
* mday: 日 (整数)
* mon: 月 (整数 1-12)
* year: 年 (整数 2000年=2000)
* wday: 曜日 (整数 0-6)
* yday: 年内通算日 (整数 1-366)
* isdst: 夏時間であるかどうか (t......rue/false)
* zone: タイムゾーン (文字列)
//emlist[][ruby]{
t = Time.local(2000,1,2,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 を返し、year は 1998 年に対して 1998 を返します。また、
yday は 1 から数えます。... -
MatchData
# byteoffset(name) -> [Integer , Integer] | [nil , nil] (8220.0) -
name という名前付きグループに対応する部分文字列のバイト単位のオフセットの 配列 [start, end] を返します。
...部分文字列がなければ
[nil, nil] を返します。
@param name 名前(シンボルか文字列)
@raise IndexError 正規表現中で定義されていない name を指定した場合に発生します。
//emlist[例][ruby]{
/(?<year>\d{4})年(?<month>\d{1,2})月(?:(?<day>\d{1,2})日)?......') # => [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] (8220.0) -
name という名前付きグループに対応する部分文字列のオフセットの配列 [start, end] を返 します。
...nd] を返
します。
//emlist[例][ruby]{
[ self.begin(name), self.end(name) ]
//}
と同じです。nameの名前付きグループにマッチした部分文字列がなければ
[nil, nil] を返します。
@param name 名前(シンボルか文字列)
@raise IndexError 正規表現中で......す。
//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 $~.offset(......'century') # => `offset': undefined group name reference: century (IndexError)
//}
@see MatchData#begin, MatchData#end......'century') # => `offset': undefined group name reference: century (IndexError)
//}
@see MatchData#begin, MatchData#end, MatchData#offset... -
MatchData
# byteoffset(n) -> [Integer , Integer] | [nil , nil] (8205.0) -
n 番目の部分文字列のバイト単位のオフセットの 配列 [start, end] を返します。
...のオフセットの
配列 [start, end] を返します。
n番目の部分文字列がマッチしていなければ [nil, nil] を返します。
@param n 部分文字列を指定する数値
@raise IndexError 範囲外の n を指定した場合に発生します。
@see MatchData#offset... -
MatchData
# offset(n) -> [Integer , Integer] | [nil , nil] (8205.0) -
n 番目の部分文字列のオフセットの配列 [start, end] を返 します。
...列 [start, end] を返
します。
//emlist[例][ruby]{
[ self.begin(n), self.end(n) ]
//}
と同じです。n番目の部分文字列がマッチしていなければ
[nil, nil] を返します。
@param n 部分文字列を指定する数値
@raise IndexError 範囲外の n を指定した......場合に発生します。
@see MatchData#begin, MatchData#end......場合に発生します。
@see MatchData#begin, MatchData#end, MatchData#offset...