クラス
- File (33)
- Module (22)
- Object (11)
- Socket (11)
-
Socket
:: AncillaryData (66)
モジュール
- Kernel (22)
キーワード
-
class
_ variables (11) -
connect
_ nonblock (11) -
convertible
_ int (22) - flock (11)
-
instance
_ variables (11) -
ip
_ pktinfo (11) -
ipv6
_ pktinfo (11) -
ipv6
_ pktinfo _ addr (11) -
ipv6
_ pktinfo _ ifindex (11) - path (11)
-
to
_ path (11) -
unix
_ rights (11)
検索結果
先頭5件
-
Module
# constants(inherit = true) -> [Symbol] (21262.0) -
そのモジュール(またはクラス)で定義されている定数名の配列を返します。
...定数は含まれません。 Object.constants とすると Object クラスで定義された
定数の配列が得られます。
得られる定数の順序は保証されません。
@param inherit true を指定するとスーパークラスや include したモジュールで
定義......数が対象にはなります。false を指定した場合 対象にはなりません。
@see Module.constants, Kernel.#local_variables, Kernel.#global_variables, Object#instance_variables, Module#class_variables
//emlist[Module.constants と Module#constants の違い][ruby]{
# 出力の簡略......て後で差し引く
$clist = Module.constants
class Foo
FOO = 1
end
class Bar
BAR = 1
# Bar は BAR を含む
p constants # => [:BAR]
# 出力に FOO は含まれない
p Module.constants - $clist # => [:BAR, :Bar, :Foo]
class Baz
# Baz は定数... -
Module
# class _ variables(inherit = true) -> [Symbol] (9113.0) -
クラス/モジュールに定義されているクラス変数の名前の配列を返します。
...rit false を指定しない場合はスーパークラスやインクルードして
いるモジュールのクラス変数を含みます。
//emlist[例][ruby]{
class One
@@var1 = 1
end
class Two < One
@@var2 = 2
end
One.class_variables # => [:@@var1]
Two.class_variables......# => [:@@var2, :@@var1]
Two.class_variables(false) # => [:@@var2]
//}
@see Module.constants, Kernel.#local_variables, Kernel.#global_variables, Object#instance_variables, Module#constants... -
Kernel
# convertible _ int(type , headers = nil , opts = nil) (6117.0) -
Returns the convertible integer type of the given +type+. You may optionally specify additional +headers+ to search in for the +type+. _Convertible_ means actually same type, or typedefed from same type. If the +type+ is a integer type and _convertible_ type is found, following macros are passed as preprocessor constants to the compiler using the +type+ name, in uppercase. * 'TYPEOF_', followed by the +type+ name, followed by '=X' where 'X' is the found _convertible_ type name. * 'TYP2NUM' and 'NUM2TYP, where 'TYP' is the +type+ name in uppercase with replacing '_t' suffix with 'T', followed by '=X' where 'X' is the macro name to convert +type+ to +Integer+ object, and vice versa. For example, if foobar_t is defined as unsigned long, then convertible_int("foobar_t") would return "unsigned long", and define macros: #define TYPEOF_FOOBAR_T unsigned long #define FOOBART2NUM ULONG2NUM #define NUM2FOOBART NUM2ULONG
...Returns the convertible integer type of the given +type+. You may
optionally specify additional +headers+ to search in for the +type+.
_Convertible_ means actually same type, or typedefed from same type.
If the +type+ is a integer type and _convertible_ type is found,
following macros are pas......to the
compiler using the +type+ name, in uppercase.
* 'TYPEOF_', followed by the +type+ name, followed by '=X' where 'X'
is the found _convertible_ type name. * 'TYP2NUM' and 'NUM2TYP,
where 'TYP' is the +type+ name in uppercase with replacing '_t'
suffix with 'T', followed by '=X' w......ert +type+ to +Integer+ object, and vice versa.
For example, if foobar_t is defined as unsigned long, then
convertible_int("foobar_t") would return "unsigned long", and define
macros:
#define TYPEOF_FOOBAR_T unsigned long
#define FOOBART2NUM ULONG2NUM
#define NUM2FOOBART NUM2ULONG... -
Kernel
# convertible _ int(type , headers = nil , opts = nil) { . . . } (6117.0) -
Returns the convertible integer type of the given +type+. You may optionally specify additional +headers+ to search in for the +type+. _Convertible_ means actually same type, or typedefed from same type. If the +type+ is a integer type and _convertible_ type is found, following macros are passed as preprocessor constants to the compiler using the +type+ name, in uppercase. * 'TYPEOF_', followed by the +type+ name, followed by '=X' where 'X' is the found _convertible_ type name. * 'TYP2NUM' and 'NUM2TYP, where 'TYP' is the +type+ name in uppercase with replacing '_t' suffix with 'T', followed by '=X' where 'X' is the macro name to convert +type+ to +Integer+ object, and vice versa. For example, if foobar_t is defined as unsigned long, then convertible_int("foobar_t") would return "unsigned long", and define macros: #define TYPEOF_FOOBAR_T unsigned long #define FOOBART2NUM ULONG2NUM #define NUM2FOOBART NUM2ULONG
...Returns the convertible integer type of the given +type+. You may
optionally specify additional +headers+ to search in for the +type+.
_Convertible_ means actually same type, or typedefed from same type.
If the +type+ is a integer type and _convertible_ type is found,
following macros are pas......to the
compiler using the +type+ name, in uppercase.
* 'TYPEOF_', followed by the +type+ name, followed by '=X' where 'X'
is the found _convertible_ type name. * 'TYP2NUM' and 'NUM2TYP,
where 'TYP' is the +type+ name in uppercase with replacing '_t'
suffix with 'T', followed by '=X' w......ert +type+ to +Integer+ object, and vice versa.
For example, if foobar_t is defined as unsigned long, then
convertible_int("foobar_t") would return "unsigned long", and define
macros:
#define TYPEOF_FOOBAR_T unsigned long
#define FOOBART2NUM ULONG2NUM
#define NUM2FOOBART NUM2ULONG... -
File
# flock(operation) -> 0 | false (6113.0) -
ファイルをロックします。
...クされます。
ロックの取得に成功した場合は 0 を返します。
File::LOCK_NB (ノンブロッキング) を指定すると、本来ならブロックされる場合に
ブロックされずに false を返すようになります。
@param operation ロックに対する操作......rror 自身が close されている場合に発生します。
@raise Errno::EXXX operation に不正な整数を与えた場合などに発生します。
引数 operation に有効な定数は以下の通りです。定数は File::Constants で定義されていますが、
File クラスの......親クラスの IO が File::Constants をインクルードしているので、
これらの定数は File::LOCK_SH などとして参照可能です。
: LOCK_SH
共有ロック。複数のプロセスが同時にロックを共有できます。
システムによってはロック対象の... -
Object
# instance _ variables -> [Symbol] (6113.0) -
オブジェクトのインスタンス変数名をシンボルの配列として返します。
...列として返します。
//emlist[][ruby]{
obj = Object.new
obj.instance_eval { @foo, @bar = nil }
p obj.instance_variables
#=> [:@foo, :@bar]
//}
@see Object#instance_variable_get, Kernel.#local_variables, Kernel.#global_variables, Module.constants, Module#constants, Module#class_variables... -
Socket
# connect _ nonblock(server _ sockaddr) -> 0 (6107.0) -
ソケットをノンブロッキングモードに設定した後、 connect(2) を呼び出します。
...ble が Object#extend されます。
これを connect_nonblock をリトライするために使うことができます。
# Pull down Google's web page
require 'socket'
include Socket::Constants
socket = Socket.new(AF_INET, SOCK_STREAM, 0)
sockaddr = Socket.sockaddr_in(80, 'www.google.......com')
begin # emulate blocking connect
socket.connect_nonblock(sockaddr)
rescue IO::WaitWritable
IO.select(nil, [socket]) # wait 3-way handshake completion
begin
socket.connect_nonblock(sockaddr) # check connection failure
rescue Errno::EISCONN
end
end
socket.write......("GET / HTTP/1.0\r\n\r\n")
results = socket.read
@param server_sockaddr 接続先アドレス
@raise Errno::EXXX connect(2) がエラーを報告した場合に発生します。詳しくは
man を参照してください。... -
Socket
:: AncillaryData # unix _ rights -> [IO] | nil (3107.0) -
Unix domain socket の SCM_RIGHTS 制御メッセージに含まれる ファイルディスクリプタを IO オブジェクトの配列として返します。
...IO オブジェクトの配列として返します。
得られる IO オブジェクトか IO か Socket です。
この配列は Socket::AncillaryData が初期化されたときに
作られます。例えば BasicSocket#recvmsg を :scm_rights => true
オプションを付けて呼びだ......nil を返します。
require 'socket'
# recvmsg needs :scm_rights=>true for unix_rights
s1, s2 = UNIXSocket.pair
p s1 #=> #<UNIXSocket:fd 3>
s1.sendmsg "stdin and a socket", 0, nil, Socket::AncillaryData.unix_rights(STDIN, s1)
_, _, _, ctl = s......2.recvmsg(:scm_rights=>true)
p ctl
#=> #<Socket::AncillaryData: UNIX SOCKET RIGHTS 6 7>
p ctl.unix_rights #=> [#<IO:fd 6>, #<Socket:fd 7>]
p File.identical?(STDIN, ctl.unix_rights[0]) #=> true
p File.identical?(s1, ctl.unix_rights[1]) #=> true
# If :scm_r... -
Socket
:: AncillaryData # timestamp -> Time (3037.0) -
タイムスタンプ制御メッセージに含まれる時刻を Time オブジェクト で返します。
...ンプ制御メッセージ" は以下のいずれかです。
* SOL_SOCKET/SCM_TIMESTAMP (micro second) GNU/Linux, FreeBSD, NetBSD, OpenBSD, Solaris, MacOS X
* SOL_SOCKET/SCM_TIMESTAMPNS (nano second) GNU/Linux
* SOL_SOCKET/SCM_BINTIME (2**(-64) second) FreeBSD
require 'socket'
Addri......local_address
ctl = s1.recvmsg.last
p ctl
#=> #<Socket::AncillaryData: INET SOCKET TIMESTAMP 2009-02-24 17:35:46.775581>
t = ctl.timestamp
p t #=> 2009-02-24 17:35:46 +0900
p t.usec #=> 775581
p t.nsec #=> 775581000
}
}
@see Socket::Constants......::SCM_TIMESTAMP,
Socket::Constants::SCM_TIMESTAMPNS,
Socket::Constants::SCM_BINTIME,
Socket::Constants::SO_TIMESTAMP,
Socket::Constants::SO_TIMESTAMPNS,
Socket::Constants::SO_BINTIME... -
File
# path -> String (3007.0) -
オープン時に使用したパスを文字列で返します。
...self に対応するファイルを指しているとは限りません。
たとえば、ファイルが移動されていたり、削除されていたり、
File::Constants::TMPFILEオプション付きで作成されていたりする場合です。
//emlist[例][ruby]{
File.open("testfile") {......|f| f.path } #=> "testfile"
File.open("/tmp/../tmp/xxx", "w") {|f| f.path } #=> "/tmp/../tmp/xxx"
File.open("/tmp", File::RDWR | File::TMPFILE){|f| f.path } #=> "/tmp"
//}...