クラス
- Dir (24)
- IO (24)
-
OpenSSL
:: SSL :: SSLSocket (12) -
OpenSSL
:: X509 :: Store (12) -
OpenSSL
:: X509 :: StoreContext (12) - TCPServer (24)
モジュール
-
OpenSSL
:: SSL (24)
キーワード
- ARGF (12)
- Cipher (12)
- DRbProtocol (12)
- IO (12)
- Marshal フォーマット (12)
-
NEWS for Ruby 3
. 0 . 0 (5) -
OP
_ CIPHER _ SERVER _ PREFERENCE (12) -
OP
_ SSLREF2 _ REUSE _ CERT _ TYPE _ BUG (12) - Ruby用語集 (12)
- binmode (12)
- binwrite (12)
- error (24)
- mktmpdir (24)
- new (12)
-
ruby 1
. 6 feature (12) -
verify
_ result (12) - クラス/メソッドの定義 (12)
- 制御構造 (12)
- 正規表現 (12)
検索結果
先頭5件
-
正規表現 (360.0)
-
正規表現 * metachar * expansion * char * anychar * string * str * quantifier * capture * grouping * subexp * selector * anchor * cond * option * encoding * comment * free_format_mode * absenceop * list * specialvar * references
...uping
* subexp
* selector
* anchor
* cond
* option
* encoding
* comment
* free_format_mode
* absenceop
* list
* specialvar
* references
正規表現(regular expression)は文字列のパターンを記述するための言語です。
また、この言語で記述された......* [:punct:] 句読点 (Connector_Punctuation | Dash_Punctuation | Close_Punctuation | Final_Punctuation | Initial_Punctuation | Other_Punctuation | Open_Punctuation)
* [:space:] 空白、改行、復帰 (Space_Separator | Line_Separator | Paragraph_Separator | 0009 | 000A | 000B | 000C | 000D | 0......$+ 最後(末尾)のキャプチャ文字列
これらの変数はスレッドローカルかつメソッドでローカルな変数です。
===[a:references] 参考文献
* 『正規表現技術入門――最新エンジン実装と理論的背景』新屋良磨、鈴木勇介、高田謙 著... -
制御構造 (288.0)
-
制御構造 条件分岐: * if * unless * case 繰り返し: * while * until * for * break * next * redo * retry 例外処理: * raise * begin その他: * return * BEGIN * END
...しで rescue, ensure 節を定義でき、これにより例外を処理することが
できます。
==== rescue修飾子
//emlist[例][ruby]{
open("nonexistent file") rescue STDERR.puts "Warning: #$!"
//}
文法:
式1 rescue 式2
式1で例外が発生したとき、式2を評価....../emlist[][ruby]{
var = open("nonexistent file") rescue false
p var
# => false
//}
ただし、優先順位の都合により式全体を括弧で囲む必要がある場合があります。
メソッドの引数にするには二重の括弧が必要です。
p(open("nonexistent file")......rescue false)
=> parse error
p((open("nonexistent file") rescue false))
=> false
=== その他
====[a:return] return
//emlist[例][ruby]{
return
return 12
return 1,2,3
//}
文法:
return [式[`,' 式 ... ]]
式の値を戻り値としてメソッドの... -
クラス/メソッドの定義 (286.0)
-
クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined
...Y = 0
WRONLY = 1
end
include Constants
end
File.open("foo", File::RDONLY)
# あるいは
include File::Constants
File.open("foo", RDONLY)
# 上記はあくまでも例である。実際の File.open ではより簡便な
# File.open("foo", "r") という形式が使われる
//}
クラ... -
Dir
. mktmpdir(prefix _ suffix = nil , tmpdir = nil) -> String (112.0) -
一時ディレクトリを作成します。
...ィレクトリのパスを
返します。この場合、このメソッドは作成した一時ディレクトリを削除しません。
@param prefix_suffix nil の場合は、'd' をデフォルトのプレフィクスとして使用します。サフィックスは付きません。......先頭に'd' をつける。
#=> /var/tmp/d20081011-5304-h6b13j
}
memory_dir = nil
Dir.mktmpdir {|dir|
memory_dir = dir
File.open("#{dir}/foo", "w") { |fp|
fp.puts "hogehoge"
}
}
# ブロックを抜けたら、テンポラリディレクトリは消される。
p......= Dir.mktmpdir
# ブロックを与えない場合は、ディレクトリは存在する。
begin
File.open("#{dir}/foo", "w") { |fp|
fp.puts "hogehoge"
}
ensure
FileUtils.remove_entry_secure dir
end
p FileTest.directory?(dir) #=> false
@raise ArgumentError tmpdirが全... -
Dir
. mktmpdir(prefix _ suffix = nil , tmpdir = nil) {|dir| . . . } -> object (112.0) -
一時ディレクトリを作成します。
...ィレクトリのパスを
返します。この場合、このメソッドは作成した一時ディレクトリを削除しません。
@param prefix_suffix nil の場合は、'd' をデフォルトのプレフィクスとして使用します。サフィックスは付きません。......先頭に'd' をつける。
#=> /var/tmp/d20081011-5304-h6b13j
}
memory_dir = nil
Dir.mktmpdir {|dir|
memory_dir = dir
File.open("#{dir}/foo", "w") { |fp|
fp.puts "hogehoge"
}
}
# ブロックを抜けたら、テンポラリディレクトリは消される。
p......= Dir.mktmpdir
# ブロックを与えない場合は、ディレクトリは存在する。
begin
File.open("#{dir}/foo", "w") { |fp|
fp.puts "hogehoge"
}
ensure
FileUtils.remove_entry_secure dir
end
p FileTest.directory?(dir) #=> false
@raise ArgumentError tmpdirが全... -
DRb
:: DRbProtocol (84.0) -
drb で使われる通信プロトコルを取り扱うモジュールです。
...e/drb/http0serv.rb などを見てください。
これらの例を見てわかるように、通信クラスでは取り扱えない URI が open
や open_server に渡された場合は例外 DRb::DRbBadScheme を
raise することで、その URI が取り扱えないことを drb ライブ......必要があります。
: open(uri, config)
uri で指定したサーバへの接続を開く。
返り値として、プロトコルクラスのインスタンスで、開いた接続を保持した
オブジェクトを返さなければなりません。
: open_server(uri, config)
サ......接続を待ち受けている uri を返します。
==== open
プロトコルクラスの open で返されるオブジェクトは以下のメソッドを
持っている必要があります。
: send_request (ref, msg_id, arg, b)
ref で指定されているオブジェクトの msg_id で... -
ruby 1
. 6 feature (54.0) -
ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。
...dev:17155>))
open("|-","r+") {|f|
if f
f.dup.close_write
else
sleep 1
end
}
=> ruby 1.6.7 (2002-03-01) [i586-linux]
-:3:in `close_write': closing non-duplex IO for writing (IOError)
from -:3
from -:1:in `open'......ルシステムでこ
のような場合があります)が File#read などで読めないバグが修正されまし
た。
p File.open("/proc/#$$/cmdline").read
=> ruby 1.6.7 (2002-03-01) [i586-linux]
""
=> ruby 1.6.7 (2002-03-29) [i586-linux]......ameError)
from -:2
ruby 1.6.7 (2002-03-01) [i586-linux]
=> ruby 1.6.7 (2002-03-15) [i586-linux]
: 2002-03-13 ((<getopts>))
refine. ((<ruby-dev:16193>)), ((<ruby-dev:16213>))
: 2002-03-11 正規表現中の 8 進コード
正規表現中の \nnn による 8 進記法... -
NEWS for Ruby 3
. 0 . 0 (48.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...`# frozen-string-literal: true` is used. 17104
* Magic comment `shareable_constant_value` added to freeze constants.
See {Magic Comments}[rdoc-ref:doc/syntax/comments.rdoc@Magic+Comments] for more details.
17273
* A {static analysis}[rdoc-label:label-Static+analysis] foundation is
in......r hooks in a non-blocking context. 16786
* Ractor
* New class added to enable parallel execution. See rdoc-ref:ractor.md for more details.
* Random
* `Random::DEFAULT` now refers to the `Random` class instead of being a `Random` instance, so it can work with `Ractor`. 17322
* `Random......efault.
* OpenStruct
* Initialization is no longer lazy. 12136
* Builtin methods can now be overridden safely. 15409
* Implementation uses only methods ending with `!`.
* Ractor compatible.
* Improved support for YAML. 8382
* Use officially discouraged. Read OpenStruct@Cave... -
IO (36.0)
-
基本的な入出力機能のためのクラスです。
...連のメソッドはエンコーディングの影響を受けません。
常に1バイトを単位として動作します。
例:
f = File.open('t.txt', 'r+:euc-jp')
p f.getc.encoding #=> Encoding::EUC_JP
p f.read(1).encoding #=> Encod......open や File.open
に渡すモードとともに指定するものと
生成後に IO#set_encoding を使って指定するものの二通りがあります。詳しくはそれぞれのメソッドの項を
参照して下さい。通常は前者の方法を使います。
例1:
f = File.open......('file1')
p f.getc.encoding #=> Encoding::EUC_JP
例2:
f = File.open('t.txt', 'w+:shift_jis:euc-jp')
f.write "\xB4\xC1\xBB\xFA" # 文字列 "漢字" の EUC-JP リテラル
f.rewind
s = f.read(4)
puts s.dump #=> "\x8A\xBF\x8E\x9A"... -
Marshal フォーマット (36.0)
-
Marshal フォーマット フォーマットバージョン 4.8 を元に記述しています。
...ラス/モジュールのインスタンス変数は dump されない][ruby]{
module Bar
@bar = 1
end
p Bar.instance_eval { @bar } # => 1
File.open('testfile', 'wb') do |f|
Marshal.dump(Bar, f)
end
# 別プログラム相当にするため remove_const
Object.send :remove_const, :Bar
module B......l
//}
//emlist[例 3: クラス変数は dump されない][ruby]{
module Baz
@@baz = 1
def self.baz
@@baz
end
end
p Baz.baz
# => 1
File.open('testfile', 'wb') do |f|
Marshal.dump(Baz, f)
end
# 別プログラム相当にするため remove_const
Object.send :remove_const, :Baz
module...