種類
- インスタンスメソッド (274)
- 特異メソッド (99)
クラス
-
ARGF
. class (11) -
Encoding
:: Converter (33) - Enumerator (22)
-
Enumerator
:: Lazy (10) - IO (146)
- MatchData (26)
- Regexp (22)
- String (4)
- Time (77)
モジュール
- Enumerable (22)
キーワード
- advise (11)
- binread (11)
- binwrite (11)
- byteindex (2)
- byteoffset (4)
- byterindex (2)
-
copy
_ stream (22) -
each
_ with _ index (22) - getlocal (22)
-
gmt
_ offset (11) - gmtoff (11)
- localtime (22)
- match (22)
- pread (7)
-
primitive
_ convert (33) - pwrite (7)
- read (33)
- seek (22)
- sysseek (11)
-
utc
_ offset (11) -
with
_ index (32) - write (22)
検索結果
先頭5件
-
MatchData
# offset(name) -> [Integer , Integer] | [nil , nil] (26353.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('centu......ry') # => `offset': undefined group name reference: century (IndexError)
//}
@see MatchData#begin, MatchData#end......ry') # => `offset': undefined group name reference: century (IndexError)
//}
@see MatchData#begin, MatchData#end, MatchData#offset... -
MatchData
# offset(n) -> [Integer , Integer] | [nil , nil] (26318.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... -
String
# byteindex(pattern , offset = 0) -> Integer | nil (17337.0) -
文字列の offset から右に向かって pattern を検索し、 最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。 見つからなければ nil を返します。
...文字列の offset から右に向かって pattern を検索し、
最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。
見つからなければ nil を返します。
引数 pattern は探索する部分文字列または正規表現で指定......aram offset 探索を開始するバイト単位のオフセット
@raise IndexError オフセットが文字列の境界以外をさしているときに発生します。
//emlist[例][ruby]{
'foo'.byteindex('f') # => 0
'foo'.byteindex('o') # => 1
'foo'.byteindex('oo') # => 1
'foo'.byteindex......=> nil
'foo'.byteindex(/f/) # => 0
'foo'.byteindex(/o/) # => 1
'foo'.byteindex(/oo/) # => 1
'foo'.byteindex(/ooo/) # => nil
'foo'.byteindex('o', 1) # => 1
'foo'.byteindex('o', 2) # => 2
'foo'.byteindex('o', 3) # => nil
'foo'.byteindex('o', -1) # => 2
'foo'.byteindex('o', -2) # => 1
'foo'.byteinde... -
String
# byterindex(pattern , offset = self . bytesize) -> Integer | nil (17331.0) -
文字列のバイト単位のインデックス offset から左に向かって pattern を探索します。 最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。 見つからなければ nil を返します。
...文字列のバイト単位のインデックス offset から左に向かって pattern を探索します。
最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。
見つからなければ nil を返します。
引数 pattern は探索する部......分文字列または正規表現で指定します。
offset が負の場合は、文字列の末尾から数えた位置から探索します。
byterindex と String#byteindex とでは、探索方向だけが逆になります。
完全に左右が反転した動作をするわけではあり......mlist[String#byteindex の場合][ruby]{
p "stringstring".byteindex("ing", 1) # => 3
# ing # ここから探索を始める
# ing
# ing # 右にずらしていってここで見つかる
//}
//emlist[String#byterindex の場合][ruby]{
p "stringstring".byterindex("in... -
Time
# gmt _ offset -> Integer (17216.0) -
協定世界時との時差を秒を単位とする数値として返します。
...//emlist[地方時の場合][ruby]{
p Time.now.zone # => "JST"
p Time.now.utc_offset # => 32400
//}
タイムゾーンが協定世界時に設定されている場合は 0 を返します。
//emlist[協定世界時の場合][ruby]{
p Time.now.getgm.zone # => "UTC"
p Time.now.getg... -
Time
# utc _ offset -> Integer (17216.0) -
協定世界時との時差を秒を単位とする数値として返します。
...//emlist[地方時の場合][ruby]{
p Time.now.zone # => "JST"
p Time.now.utc_offset # => 32400
//}
タイムゾーンが協定世界時に設定されている場合は 0 を返します。
//emlist[協定世界時の場合][ruby]{
p Time.now.getgm.zone # => "UTC"
p Time.now.getg... -
Time
# localtime(utc _ offset) -> self (17209.0) -
タイムゾーンを地方時に設定します。
...utc_offset タイムゾーンを地方時に設定する代わりに協定世界時との
時差を、秒を単位とする整数か、"+HH:MM" "-HH:MM" 形式
の文字列で指定します。
Time#localtime, Time#gmtime の挙動はシステムの
localtime(3)......存します。Time クラ
スでは時刻を起算時からの経過秒数として保持していますが、ある特定の
時刻までの経過秒は、システムがうるう秒を勘定するかどうかによって異
なる場合があります。システムを越えて Time オブジェ......。
//emlist[][ruby]{
p t = Time.utc(2000, "jan", 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
p t.utc? # => true
p t.localtime # => 2000-01-02 05:15:01 +0900
p t.utc? # => false
p t.localtime("+09:00")... -
Time
# localtime -> self (17109.0) -
タイムゾーンを地方時に設定します。
...utc_offset タイムゾーンを地方時に設定する代わりに協定世界時との
時差を、秒を単位とする整数か、"+HH:MM" "-HH:MM" 形式
の文字列で指定します。
Time#localtime, Time#gmtime の挙動はシステムの
localtime(3)......存します。Time クラ
スでは時刻を起算時からの経過秒数として保持していますが、ある特定の
時刻までの経過秒は、システムがうるう秒を勘定するかどうかによって異
なる場合があります。システムを越えて Time オブジェ......。
//emlist[][ruby]{
p t = Time.utc(2000, "jan", 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
p t.utc? # => true
p t.localtime # => 2000-01-02 05:15:01 +0900
p t.utc? # => false
p t.localtime("+09:00")... -
IO
. binwrite(path , string , offset=nil) -> Integer (14421.0) -
path で指定されるファイルを開き、string を書き込み、 閉じます。
...path で指定されるファイルを開き、string を書き込み、
閉じます。
ファイルを開くときの mode が "rb:ASCII-8BIT" で、バイナリモードが有効
である点以外は IO.write と同じです。
Kernel.#open と同様 path の先頭が "|" ならば、"|" に......ます。
offset を指定するとその位置までシークします。
offset を指定しないと、書き込みの末尾でファイルを
切り捨てます。
@param path ファイル名文字列
@param string 書き込む文字列
@param offset 書き込み開始位置
//emlist[例][ru......像データ。
png = 'iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAAAAADhZOFXAAAADklEQVQIW2P4DwUMlDEA98A/wTjP
QBoAAAAASUVORK5CYII='.unpack('m').first
# 期待する先頭16バイトの16進ダンプ: どの環境でも同じ。
puts png[0...16].unpack('C*').map {|c| '%02x' % c }.join(' ')
# => 89 50 4e 47 0d... -
IO
. binread(path , length = nil , offset = 0) -> String | nil (14319.0) -
path で指定したファイルを open し、offset の所まで seek し、 length バイト読み込みます。
...path で指定したファイルを open し、offset の所まで seek し、
length バイト読み込みます。
Kernel.#open と同様 path の先頭が "|" ならば、"|" に続くコマンドの出力を読み取ります。
length を省略するとファイルの末尾まで読み込み......SCII-8BIT" です。
//emlist[例][ruby]{
IO.write("testfile", "This is line one\nThis is line two\nThis is line three\nAnd so on...\n")
IO.binread("testfile") # => "This is line one\nThis is line two\nThis is line three\nAnd so on...\n"
IO.binread("testfile", 20) # => "This is line......one\nThi"
IO.binread("testfile", 20, 10) # => "ne one\nThis is line "
//}
@see IO.read... -
MatchData
# byteoffset(name) -> [Integer , Integer] | [nil , nil] (14315.0) -
name という名前付きグループに対応する部分文字列のバイト単位のオフセットの 配列 [start, end] を返します。
...プにマッチした部分文字列がなければ
[nil, nil] を返します。
@param name 名前(シンボルか文字列)
@raise IndexError 正規表現中で定義されていない name を指定した場合に発生します。
//emlist[例][ruby]{
/(?<year>\d{4})年(?<month>\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
# byteoffset(n) -> [Integer , Integer] | [nil , nil] (14310.0) -
n 番目の部分文字列のバイト単位のオフセットの 配列 [start, end] を返します。
...のオフセットの
配列 [start, end] を返します。
n番目の部分文字列がマッチしていなければ [nil, nil] を返します。
@param n 部分文字列を指定する数値
@raise IndexError 範囲外の n を指定した場合に発生します。
@see MatchData#offset... -
Enumerator
# with _ index(offset = 0) -> Enumerator (14238.0) -
生成時のパラメータに従って、要素にインデックスを添えて繰り返します。 インデックスは offset から始まります。
...ンデックスは offset から始まります。
ブロックを指定した場合の戻り値は生成時に指定したレシーバ自身です。
//emlist[例][ruby]{
str = "xyz"
enum = Enumerator.new {|y| str.each_byte {|b| y << b }}
enum.with_index {|byte, idx| p [byte, idx] }
# => [12......0, 0]
# [121, 1]
# [122, 2]
require "stringio"
StringIO.new("foo|bar|baz").each("|").with_index(1) {|s, i| p [s, i] }
# => ["foo|", 1]
# ["bar|", 2]
# ["baz", 3]
//}
生成時のパラメータに従って、要素にインデックスを添えてブロックを繰......り返します。
インデックスは 0 から始まります。
Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。...