ライブラリ
- ビルトイン (343)
- json (11)
- optparse (22)
- prettyprint (11)
- psych (25)
- shell (6)
-
shell
/ command-processor (6) -
shell
/ filter (6) - socket (11)
- time (55)
- zlib (44)
クラス
- Array (44)
-
Encoding
:: Converter (44) - Enumerator (11)
-
Enumerator
:: ArithmeticSequence (24) - Exception (11)
-
File
:: Stat (11) -
JSON
:: State (11) - LoadError (11)
- MatchData (44)
- OptionParser (22)
- PrettyPrint (11)
- Random (33)
- Regexp (22)
- Shell (6)
-
Shell
:: CommandProcessor (6) -
Shell
:: Filter (6) - StopIteration (11)
- SystemExit (11)
- Thread (22)
- Time (55)
- UDPSocket (11)
-
Zlib
:: GzipReader (33) -
Zlib
:: Inflate (11)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) - == (6)
-
NEWS for Ruby 2
. 5 . 0 (7) - Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (11)
- Status (11)
- [] (33)
- accept (22)
-
backtrace
_ locations (11) -
check
_ circular? (11) - each (11)
-
each
_ byte (11) -
each
_ line (11) - end (17)
- exit (11)
- exit! (11)
- format (11)
-
handle
_ interrupt (11) - hash (6)
- httpdate (11)
- iso8601 (11)
-
last
_ match (22) - load (14)
- mkdir (18)
- next (11)
- offset (22)
- parse (11)
- path (11)
-
primitive
_ convert (44) - rand (33)
- rdoc (11)
-
recvfrom
_ nonblock (11) - require (11)
- result (11)
- rfc2822 (11)
- rfc822 (11)
-
ruby 1
. 6 feature (11) -
set
_ dictionary (11) - status (11)
- sticky? (11)
- terminate (11)
- xmlschema (11)
- 制御構造 (11)
検索結果
先頭5件
-
MatchData
# begin(n) -> Integer | nil (24137.0) -
n 番目の部分文字列先頭のオフセットを返します。
...範囲外の n を指定した場合に発生します。
//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.begin(0) # => 0
p $~.begin(1) # => 0
p $~.begin(2) # => 3
p $~.begin(3) # => nil
p $~.begin(4) # => `begin': index 4 out of matches (IndexError)
//}
@see MatchData#end... -
Enumerator
:: ArithmeticSequence # begin -> Numeric (21101.0) -
初項 (始端) を返します。
...初項 (始端) を返します。
@see Enumerator::ArithmeticSequence#end... -
Enumerator
:: ArithmeticSequence # begin -> Numeric | nil (21101.0) -
初項 (始端) を返します。
...初項 (始端) を返します。
@see Enumerator::ArithmeticSequence#end... -
Array
# at(nth) -> object | nil (15106.0) -
nth 番目の要素を返します。nth 番目の要素が存在しない時には nil を返します。
nth 番目の要素を返します。nth 番目の要素が存在しない時には nil を返します。
@param nth インデックスを整数で指定します。
先頭の要素が 0 番目になります。nth の値が負の時には末尾から
のインデックスと見倣します。末尾の要素が -1 番目になります。
整数以外のオブジェクトを指定した場合は to_int メソッドによる
暗黙の型変換を試みます。
@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定... -
Regexp
. last _ match -> MatchData (6301.0) -
カレントスコープで最後に行った正規表現マッチの MatchData オ ブジェクトを返します。このメソッドの呼び出しは $~ の参照と同じです。
...MatchData オ
ブジェクトを返します。このメソッドの呼び出しは $~
の参照と同じです。
//emlist[例][ruby]{
/(.)(.)/ =~ "ab"
p Regexp.last_match # => #<MatchData:0x4599e58>
p Regexp.last_match[0] # => "ab"
p Regexp.last_match[1] # => "a"
p Regexp.last_match[2]......# => "b"
p Regexp.last_match[3] # => nil
//}... -
Exception
# backtrace _ locations -> [Thread :: Backtrace :: Location] (6206.0) -
バックトレース情報を返します。Exception#backtraceに似ていますが、 Thread::Backtrace::Location の配列を返す点が異なります。
...が、
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>'", "test.rb:9:in `get_exception'", "test.rb:1... -
Time
. httpdate(date) -> Time (6206.0) -
2616で定義されているHTTP-dateとしてdateをパースして Timeオブジェクトに変換します。
...るHTTP-dateとしてdateをパースして
Timeオブジェクトに変換します。
dateが2616に準拠していない、または
Timeクラスが指定された日時を表現できないときにArgumentErrorが
発生します。
@param date 2616で定義されているHTTP-dateとして......定します。
@raise ArgumentError dateが2616に準拠していない、または Timeクラスが指定された日時を表現できないときに発生します。
require 'time'
rfc2616_time = 'Sun, 31 Aug 2008 12:34:56 GMT'
t = Time.httpdate(rfc2616_time)
p t.kind_of?(Time) #=> t......rue
non_rfc2616_time = 'San, 31 Aug 2008 12:34:56 GMT'
begin
Time.httpdate(non_rfc2616_time)
rescue ArgumentError => err
puts err #=> not RFC 2616 compliant date: "San, 31 Aug 2008 12:34:56 GMT"
end... -
SystemExit
# status -> Integer (6112.0) -
例外オブジェクトに保存された終了ステータスを返します。
...します。
終了ステータスは Kernel.#exit や SystemExit.new などで設定されます。
例:
begin
exit 1
rescue SystemExit => err
p err.status # => 1
end
begin
raise SystemExit.new(1, "dummy exit")
rescue SystemExit => err
p err.status # => 1
end... -
LoadError
# path -> String | nil (6106.0) -
Kernel.#require や Kernel.#load に失敗したパスを返します。
...Kernel.#require や Kernel.#load に失敗したパスを返します。
begin
require 'this/file/does/not/exist'
rescue LoadError => e
e.path # => 'this/file/does/not/exist'
end
パスが定まらない場合は nil を返します。... -
PrettyPrint
. format(output = & # 39;& # 39; , maxwidth = 79 , newline = "\n" , genspace = lambda{|n| & # 39; & # 39; * n}) {|pp| . . . } -> object (6106.0) -
PrettyPrint オブジェクトを生成し、それを引数としてブロックを実行します。 与えられた output を返します。
...t を返します。
以下と同じ働きをするもので簡便のために用意されています。
//emlist[][ruby]{
require 'prettyprint'
begin
pp = PrettyPrint.new(output, maxwidth, newline, &genspace)
...
pp.flush
output
end
//}
@param output 出力先を指定します。outpu... -
Regexp
. last _ match(nth) -> String | nil (6106.0) -
整数 nth が 0 の場合、マッチした文字列を返します ($&)。それ以外では、nth 番目の括弧にマッチ した部分文字列を返します($1,$2,...)。 対応する括弧がない場合やマッチしなかった場合には nil を返し ます。
...b"
p Regexp.last_match # => #<MatchData:0x4599e58>
p Regexp.last_match(0) # => "ab"
p Regexp.last_match(1) # => "a"
p Regexp.last_match(2) # => "b"
p Regexp.last_match(3) # => nil
//}
正規表現全体がマッチしなかった場合、引数なしの
Regexp.last_match はnil を返......すため、
last_match[1] の形式では例外 NoMethodError が発生します。
対して、last_match(1) は nil を返します。
//emlist[例][ruby]{
str = "This is Regexp"
/That is Regexp/ =~ str
p Regexp.last_match # => nil
begin
p Regexp.last_match[1] # 例外が発生する
rescue......puts $! # => undefined method `[]' for nil:NilClass
end
p Regexp.last_match(1) # => nil
//}
@param nth 整数を指定します。
整数 nth が 0 の場合、マッチした文字列を返します。それ以外では、nth 番目の括弧にマッチした部分文字列を返します。...