ライブラリ
- ビルトイン (752)
- csv (42)
- date (4)
-
fiddle
/ import (36) -
json
/ add / struct (24) - objspace (12)
- ostruct (19)
- rake (12)
-
rexml
/ document (36) - socket (12)
クラス
- Addrinfo (12)
- Array (31)
- CSV (36)
-
CSV
:: Row (6) - Data (6)
- Date (2)
- DateTime (2)
-
Fiddle
:: CStruct (12) - Hash (10)
- MatchData (4)
- OpenStruct (19)
-
REXML
:: Instruction (24) -
Rake
:: Application (12) - Range (12)
- RubyVM (12)
-
RubyVM
:: InstructionSequence (246) - String (12)
- Struct (371)
- Time (2)
- TracePoint (7)
モジュール
-
Fiddle
:: Importer (24) - ObjectSpace (60)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) - == (12)
- Data (3)
-
Data
_ Get _ Struct (12) -
Data
_ Make _ Struct (12) -
Data
_ Wrap _ Struct (12) -
INSTRUCTION
_ NAMES (12) - Instruction (12)
- InstructionSequence (12)
- Marshal フォーマット (12)
-
NEWS for Ruby 2
. 0 . 0 (12) -
NEWS for Ruby 2
. 2 . 0 (11) -
NEWS for Ruby 2
. 3 . 0 (10) -
NEWS for Ruby 3
. 1 . 0 (4) - RSTRING (12)
-
RUBY
_ DATA _ FUNC (12) - [] (24)
- []= (12)
-
absolute
_ path (12) -
base
_ label (12) - bigdecimal (12)
- compile (12)
-
compile
_ file (12) -
compile
_ option (12) -
compile
_ option= (12) - content (12)
- convert (36)
-
count
_ tdata _ objects (12) - deconstruct (14)
-
deconstruct
_ keys (20) - dig (30)
- disasm (24)
- disassemble (24)
- each (24)
-
each
_ object (48) -
each
_ pair (24) - eql? (12)
- eval (12)
-
fiddle
/ import (12) - filter (14)
-
first
_ lineno (12) - hash (12)
- inspect (24)
-
instruction
_ sequence (7) -
json
/ add / ostruct (12) -
json
/ add / struct (12) -
json
_ create (12) -
keyword
_ init? (4) - label (12)
- length (12)
-
load
_ from _ binary (10) -
load
_ from _ binary _ extra _ data (10) - members (24)
- new (72)
- of (12)
- pack (21)
- pack テンプレート文字列 (12)
- path (12)
-
rb
_ thread _ select (1) -
rexml
/ document (12) -
ruby 1
. 6 feature (12) -
ruby 1
. 8 . 2 feature (12) -
ruby 1
. 9 feature (12) - select (24)
- size (24)
- socket (12)
- target (12)
-
to
_ a (24) -
to
_ binary (10) -
to
_ h (38) -
to
_ json (12) -
to
_ s (12) - union (12)
- unpack (12)
- values (12)
-
values
_ at (12) - yaml (12)
-
yaml
/ store (12)
検索結果
先頭5件
-
Fiddle
:: Importer # struct(signature) -> Class (24235.0) -
C の構造体型に対応する Ruby のクラスを構築して返します。
...型に対応する Ruby のクラスを構築して返します。
構造体の各要素は C と似せた表記ができます。そしてそれを
配列で signature に渡してデータを定義します。例えば C における
struct timeval {
long tv_sec;
long tv_usec;
};
と......対応して
Timeval = struct(["long tv_sec", "long tv_usec"])
として構造体に対応するクラスを生成します。
このメソッドが返すクラスには以下のメソッドが定義されています
* クラスメソッド malloc
* initialize
* to_ptr
* to_i
* 構造......Fiddle::CStruct を継承しています。詳しくは
そちらを参照してください。
@param signature 構造体の各要素を文字列で表現したものの配列
require 'fiddle/import'
module M
extend Fiddle::Importer
dlload "libc.so.6"
extern "int gettimeofday(... -
Struct
# deconstruct -> [object] (24230.0) -
構造体のメンバの値を配列にいれて返します。
...列にいれて返します。
//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_a
# => ["Joe Smith", "123 Maple, Anytown NC", 12345]
//}
[注意] 本メソッドの記述は Struct の下位クラスのインスタンス......に対して呼び
出す事を想定しています。Struct.new は Struct の下位クラスを作成する点に
注意してください。
@see d:spec/pattern_matching#matching_non_primitive_objects... -
Struct
# deconstruct _ keys(array _ of _ names) -> Hash (24230.0) -
self のメンバの名前と値の組を Hash で返します。
...のメンバを意味します。
//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
h = joe.deconstruct_keys([:zip, :address])
h # => {:zip=>12345, :address=>"123 Maple, Anytown NC"}
# 引数が nil の場合は全て......。
h = joe.deconstruct_keys(nil)
h # => {:name=>"Joseph Smith, Jr.", :address=>"123 Maple, Anytown NC", :zip=>12345}
//}
[注意] 本メソッドの記述は Struct の下位クラスのインスタンスに対して呼び
出す事を想定しています。Struct.new は Struct の下位クラ......スを作成する点に
注意してください。
@see d:spec/pattern_matching#matching_non_primitive_objects... -
Struct
# to _ a -> [object] (21130.0) -
構造体のメンバの値を配列にいれて返します。
...列にいれて返します。
//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_a
# => ["Joe Smith", "123 Maple, Anytown NC", 12345]
//}
[注意] 本メソッドの記述は Struct の下位クラスのインスタンス......に対して呼び
出す事を想定しています。Struct.new は Struct の下位クラスを作成する点に
注意してください。
@see d:spec/pattern_matching#matching_non_primitive_objects... -
Struct
# values -> [object] (18130.0) -
構造体のメンバの値を配列にいれて返します。
...列にいれて返します。
//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_a
# => ["Joe Smith", "123 Maple, Anytown NC", 12345]
//}
[注意] 本メソッドの記述は Struct の下位クラスのインスタンス......に対して呼び
出す事を想定しています。Struct.new は Struct の下位クラスを作成する点に
注意してください。
@see d:spec/pattern_matching#matching_non_primitive_objects... -
TracePoint
# instruction _ sequence -> RubyVM :: InstructionSequence (15506.0) -
script_compiledイベント発生時にコンパイルされた RubyVM::InstructionSequenceインスタンスを返します。
...pt_compiledイベント発生時にコンパイルされた
RubyVM::InstructionSequenceインスタンスを返します。
//emlist[例][ruby]{
TracePoint.new(:script_compiled) do |tp|
p tp.instruction_sequence # => <RubyVM::InstructionSequence:block in <main>@(eval):1>
end.enable do
eval("put......s 'hello'")
end
//}
@raise RuntimeError :script_compiled イベントのための
イベントフックの外側で実行した場合に発生します。... -
RubyVM
:: INSTRUCTION _ NAMES -> [String] (15300.0) -
RubyVM の命令シーケンスの名前の一覧を返します。
...
RubyVM の命令シーケンスの名前の一覧を返します。
@see RubyVM::InstructionSequence... -
Struct
. json _ create(hash) -> Struct (15217.0) -
JSON のオブジェクトから Ruby のオブジェクトを生成して返します。
...JSON のオブジェクトから Ruby のオブジェクトを生成して返します。
@param hash 適切なキーを持つハッシュを指定します。... -
RubyVM
:: InstructionSequence . load _ from _ binary _ extra _ data(binary) -> String (15206.0) -
バイナリフォーマットの文字列から埋め込まれたextra_dataを取り出します。
...埋め込まれたextra_dataを取り出します。
//emlist[例][ruby]{
iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
binary = iseq.to_binary("extra_data")
RubyVM::InstructionSequence.load_from_binary_extra_data(binary) # => extra_data
//}
@see RubyVM::InstructionSequence#to_binary... -
Struct
# to _ h -> Hash (15142.0) -
self のメンバ名(Symbol)と値の組を Hash にして返します。
...(Symbol)と値の組を Hash にして返します。
//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_h
# => {:name=>"Joe Smith", :address=>"123 Maple, Anytown NC", :zip=>12345}
//}
ブロックを指定すると各ペ......ます。
//emlist[ブロック付きの例][ruby]{
Customer = Struct.new(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_h {|member, value|
[member, value*2]
} # => {:name=>"Joe SmithJoe Smith", :address=>"123 Maple, Anytown NC123 Maple, Anytown NC", :zip=>2469......0}
//}
[注意] 本メソッドの記述は Struct の下位クラスのインスタンスに対して呼び
出す事を想定しています。Struct.new は Struct の下位クラスを作成する点に
注意してください。... -
Struct
# to _ h {|member , value| block } -> Hash (15142.0) -
self のメンバ名(Symbol)と値の組を Hash にして返します。
...(Symbol)と値の組を Hash にして返します。
//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_h
# => {:name=>"Joe Smith", :address=>"123 Maple, Anytown NC", :zip=>12345}
//}
ブロックを指定すると各ペ......ます。
//emlist[ブロック付きの例][ruby]{
Customer = Struct.new(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_h {|member, value|
[member, value*2]
} # => {:name=>"Joe SmithJoe Smith", :address=>"123 Maple, Anytown NC123 Maple, Anytown NC", :zip=>2469......0}
//}
[注意] 本メソッドの記述は Struct の下位クラスのインスタンスに対して呼び
出す事を想定しています。Struct.new は Struct の下位クラスを作成する点に
注意してください。... -
Struct
. keyword _ init? -> bool | nil (15140.0) -
(このメソッドは Struct の下位クラスにのみ定義されています) 構造体が作成されたときに keyword_init: true を指定されていたら true を返します。 false を指定されていたら false を返します。 それ以外の場合は nil を返します。
...は Struct の下位クラスにのみ定義されています)
構造体が作成されたときに keyword_init: true を指定されていたら true を返します。
false を指定されていたら false を返します。
それ以外の場合は nil を返します。
//emlist[例][ruby]{......Foo = Struct.new(:a)
Foo.keyword_init? # => nil
Bar = Struct.new(:a, keyword_init: true)
Bar.keyword_init? # => true
Baz = Struct.new(:a, keyword_init: false)
Baz.keyword_init? # => false
//}... -
Struct
# inspect -> String (15136.0) -
self の内容を人間に読みやすい文字列にして返します。
...述は Struct の下位クラスのインスタンスに対して呼び
出す事を想定しています。Struct.new は Struct の下位クラスを作成する点に
注意してください。
//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Smith", "12......3 Maple, Anytown NC", 12345)
joe.inspect # => "#<struct Customer name=\"Joe Smith\", address=\"123 Maple, Anytown NC\", zip=12345>"
//}...