別のキーワード
クラス
- Array (69)
- Dir (12)
- Enumerator (24)
- Exception (24)
- Fiber (4)
-
File
:: Stat (36) - IO (36)
- Method (12)
- Module (12)
- Object (30)
- Random (36)
- Range (40)
-
RubyVM
:: InstructionSequence (24) - String (24)
-
Thread
:: Queue (40) -
Thread
:: SizedQueue (30) - Time (24)
- UnboundMethod (12)
モジュール
- Enumerable (176)
キーワード
- <=> (12)
- == (12)
- === (7)
- all? (32)
- any? (32)
- autoload (12)
-
backtrace
_ locations (12) - ceil (6)
- cover? (19)
- crypt (12)
- deq (20)
-
each
_ with _ index (24) - entries (19)
- fcntl (12)
- fdatasync (12)
-
first
_ lineno (12) - floor (6)
- flush (12)
- none? (32)
-
num
_ waiting (10) - one? (32)
- pack (21)
- pop (20)
- rand (36)
- read (12)
- round (12)
- sample (48)
- shift (20)
- size? (12)
-
source
_ location (24) - symlink? (12)
- then (14)
-
to
_ a (31) - transfer (4)
- unpack (12)
-
with
_ index (24) -
yield
_ self (16)
検索結果
先頭5件
-
File
:: Stat # <=>(o) -> Integer | nil (6115.0) -
ファイルの最終更新時刻を比較します。self が other よりも 新しければ正の数を、等しければ 0 を古ければ負の数を返します。 比較できない場合は nil を返します。
...mlist[][ruby]{
require 'tempfile' # for Tempfile
fp1 = Tempfile.open("first")
fp1.print "古い方\n"
sleep(1)
fp2 = Tempfile.open("second")
fp2.print "新しい方\n"
p File::Stat.new(fp1.path) <=> File::Stat.new(fp2.path) #=> -1
p File::Stat.new(fp2.path) <=> File::Stat.new(fp1.path) #=> 1
p Fi......le::Stat.new(fp1.path) <=> fp2.path #=> nil
//}... -
RubyVM
:: InstructionSequence # to _ a -> Array (3121.0) -
self の情報を 14 要素の配列にして返します。
...シーケンスのラ
ベル。トップレベルでは "<main>"。文字列から作成していた場合は
"<compiled>"。
: #path
命令シーケンスの相対パス。文字列から作成していた場合は "<compiled>"。
: #absolute_path
命令シーケンスの絶対パス。......配列。
: args
引数の指定が必須のメソッド、ブロックの引数の個数。あるいは以下のよう
な配列。
[required_argc, [optional_arg_labels, ...],
splat_index, post_splat_argc, post_splat_index,
block_index, simple]
より詳細な情報につい......//emlist[例][ruby]{
require 'pp'
iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
pp iseq.to_a
# ※ Ruby 2.5.0 での実行結果
# => ["YARVInstructionSequence/SimpleDataFormat",
# 2,
# 0,
# 1,
# {:arg_size=>0, :local_size=>2, :stack_max=>2},
# "<compiled>",
# "<compiled>",
# nil,
# 1,... -
RubyVM
:: InstructionSequence # first _ lineno -> Integer (3109.0) -
self が表す命令シーケンスの 1 行目の行番号を返します。
...の 1 行目の行番号を返します。
例1:irb で実行した場合
RubyVM::InstructionSequence.compile('num = 1 + 2').first_lineno
# => 1
例2:
# /tmp/method.rb
require "foo-library"
def foo
p :foo
end
RubyVM::InstructionSequence.of(method(:foo)).first_lineno
# => 2... -
Array
# pack(template) -> String (721.0) -
配列の内容を template で指定された文字列にしたがって、 バイナリとしてパックした文字列を返します。
...buffer のサイズ(capacity)が足りなければ、packはメモリを確保します。
//emlist[例][ruby]{
['!'].pack('@1a', buffer: 'abc') # => "a!"
['!'].pack('@5a', buffer: 'abc') # => "abc\u0000\u0000!"
//}
@param template 自身のバイナリとしてパックするためのテンプ......ます。
強制的にエンディアンを指定したいときは、
リトルエンディアンなら < を、
ビッグエンディアンなら >
を後ろにつけます。! と組み合わせることも可能です。
まとめると以下のようになります。
: エンディアン非......q: int64_t
Q: uint64_t
//}
: エンディアンの強制指定(バイナリ解析などに適切)
//emlist{
S>: big endian unsigned 16bit(nと同じ)
s>: big endian int16_t
s!>: big endian signed short
l<: little endian int32_t
l!<: little endian signed long
//}
=== 各テンプレ... -
Array
# pack(template , buffer: String . new) -> String (721.0) -
配列の内容を template で指定された文字列にしたがって、 バイナリとしてパックした文字列を返します。
...buffer のサイズ(capacity)が足りなければ、packはメモリを確保します。
//emlist[例][ruby]{
['!'].pack('@1a', buffer: 'abc') # => "a!"
['!'].pack('@5a', buffer: 'abc') # => "abc\u0000\u0000!"
//}
@param template 自身のバイナリとしてパックするためのテンプ......ます。
強制的にエンディアンを指定したいときは、
リトルエンディアンなら < を、
ビッグエンディアンなら >
を後ろにつけます。! と組み合わせることも可能です。
まとめると以下のようになります。
: エンディアン非......q: int64_t
Q: uint64_t
//}
: エンディアンの強制指定(バイナリ解析などに適切)
//emlist{
S>: big endian unsigned 16bit(nと同じ)
s>: big endian int16_t
s!>: big endian signed short
l<: little endian int32_t
l!<: little endian signed long
//}
=== 各テンプレ... -
Array
# pack(template) -> String (715.0) -
配列の内容を template で指定された文字列にしたがって、 バイナリとしてパックした文字列を返します。
...ます。
強制的にエンディアンを指定したいときは、
リトルエンディアンなら < を、
ビッグエンディアンなら >
を後ろにつけます。! と組み合わせることも可能です。
まとめると以下のようになります。
: エンディアン非......q: int64_t
Q: uint64_t
//}
: エンディアンの強制指定(バイナリ解析などに適切)
//emlist{
S>: big endian unsigned 16bit(nと同じ)
s>: big endian int16_t
s!>: big endian signed short
l<: little endian int32_t
l!<: little endian signed long
//}
=== 各テンプレ......][ruby]{
["abc"].pack("a") # => "a"
["abc"].pack("a*") # => "abc"
["abc"].pack("a4") # => "abc\x00"
"abc\0".unpack("a4") # => ["abc\x00"]
"abc ".unpack("a4") # => ["abc "]
//}
: A
ASCII文字列(スペースを詰める/後続するヌル文字やスペースを削除)
//emlist[][ruby]{... -
String
# unpack(template) -> Array (715.0) -
Array#pack で生成された文字列を テンプレート文字列 template にしたがってアンパックし、 それらの要素を含む配列を返します。
...ます。
強制的にエンディアンを指定したいときは、
リトルエンディアンなら < を、
ビッグエンディアンなら >
を後ろにつけます。! と組み合わせることも可能です。
まとめると以下のようになります。
: エンディアン非......q: int64_t
Q: uint64_t
//}
: エンディアンの強制指定(バイナリ解析などに適切)
//emlist{
S>: big endian unsigned 16bit(nと同じ)
s>: big endian int16_t
s!>: big endian signed short
l<: little endian int32_t
l!<: little endian signed long
//}
=== 各テンプレ......][ruby]{
["abc"].pack("a") # => "a"
["abc"].pack("a*") # => "abc"
["abc"].pack("a4") # => "abc\x00"
"abc\0".unpack("a4") # => ["abc\x00"]
"abc ".unpack("a4") # => ["abc "]
//}
: A
ASCII文字列(スペースを詰める/後続するヌル文字やスペースを削除)
//emlist[][ruby]{... -
Module
# autoload(const _ name , feature) -> nil (143.0) -
定数 const_name を最初に参照した時に feature を Kernel.#require するように設定します。
...定数 const_name を最初に参照した時に feature を Kernel.#require するように設定します。
const_name が autoload 設定されていて、まだ定義されてない(ロードされていない)ときは、
autoload する対象を置き換えます。
const_name が(autoload......。
@param feature Kernel.#require と同様な方法で autoload する対象を指定する。
//emlist[例][ruby]{
# ------- /tmp/foo.rb ---------
class Foo
class Bar
end
end
# ----- end of /tmp/foo.rb ----
class Foo
autoload :Bar, '/tmp/foo'
end
p Foo::Bar #=> Foo::Bar
//}
以下のよ......ーバとして呼び出すこともできます。
//emlist[例][ruby]{
# ------- /tmp/foo.rb ---------
class Foo
class Bar
end
end
# ----- end of /tmp/foo.rb ----
class Foo
end
Foo.autoload :Bar, '/tmp/foo'
p Foo::Bar #=> Foo::Bar
//}
以下のように、autoload したライブラリが... -
Enumerable
# all? -> bool (133.0) -
すべての要素が真である場合に true を返します。 偽である要素があれば、ただちに false を返します。
...します。
自身に要素が存在しない場合は true を返します。
//emlist[例][ruby]{
require 'set'
# すべて正の数か?
p Set[5, 6, 7].all? {|v| v > 0 } # => true
p Set[5, -1, 7].all? {|v| v > 0 } # => false
p Set[].all? {|v| v > 0 } # => true
//}......例][ruby]{
require 'set'
# すべて正の数か?
p Set[5, 6, 7].all? {|v| v > 0 } # => true
p Set[5, -1, 7].all? {|v| v > 0 } # => false
p Set[].all? {|v| v > 0 } # => true
p Set['ant', 'bear', 'cat'].all?(/t/) # => false
p (1..4).all?(Integer) # => tru......e
p [1, 2, 3].all?(Integer) # => true
p [1, 2, 3.0].all?(Integer) # => false
# Hashは[k, v]のペアなのでArray/Hash === [k, v]で評価
p({foo: 0, bar: 1}.all?(Array)) # => true
p({foo: 0, bar: 1}.all?(Hash)) # => false
//}......e
p [1, 2, 3].all?(Integer) # => true
p [1, 2, 3.0].all?(Integer) # => false
# Hashは[k, v]のペアなのでArray/Hash === [k, v]で評価
p({foo: 0, bar: 1}.all?(Array)) # => true
p({foo: 0, bar: 1}.all?(Hash)) # => false
//}
@see Array#all?... -
Enumerable
# all? {|item| . . . } -> bool (133.0) -
すべての要素が真である場合に true を返します。 偽である要素があれば、ただちに false を返します。
...します。
自身に要素が存在しない場合は true を返します。
//emlist[例][ruby]{
require 'set'
# すべて正の数か?
p Set[5, 6, 7].all? {|v| v > 0 } # => true
p Set[5, -1, 7].all? {|v| v > 0 } # => false
p Set[].all? {|v| v > 0 } # => true
//}......例][ruby]{
require 'set'
# すべて正の数か?
p Set[5, 6, 7].all? {|v| v > 0 } # => true
p Set[5, -1, 7].all? {|v| v > 0 } # => false
p Set[].all? {|v| v > 0 } # => true
p Set['ant', 'bear', 'cat'].all?(/t/) # => false
p (1..4).all?(Integer) # => tru......e
p [1, 2, 3].all?(Integer) # => true
p [1, 2, 3.0].all?(Integer) # => false
# Hashは[k, v]のペアなのでArray/Hash === [k, v]で評価
p({foo: 0, bar: 1}.all?(Array)) # => true
p({foo: 0, bar: 1}.all?(Hash)) # => false
//}
@see Array#all?...