るりまサーチ

最速Rubyリファレンスマニュアル検索!
54件ヒット [1-54件を表示] (0.110秒)

別のキーワード

  1. struct new
  2. mkmf have_struct_member
  3. struct select
  4. struct members
  5. struct each

ライブラリ

クラス

キーワード

検索結果

Struct#size -> Integer (24144.0)

構造体のメンバの数を返します。

...の記述は Struct の下位クラスのインスタンスに対して呼び
出す事を想定しています。Struct.new Struct の下位クラスを作成する点に
注意してください。

//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Smith...

Struct#[](member) -> object (9061.0)

構造体のメンバの値を返します。

...指定した場合に発生します。

//emlist[例][ruby]{
Foo = Struct.new(:foo, :bar)
obj = Foo.new('FOO', 'BAR')
p obj[:foo] # => "FOO"
p obj['bar'] # => "BAR"
# p obj[:baz] # => in `[]': no member 'baz' in struct (NameError)
p obj[0] # => "FOO"
p obj[1] # => "BAR"
p o...
...p obj[2] # => in `[]': offset 2 too large for struct(size:2) (IndexError)
//}

[注意] 本メソッドの記述は Struct の下位クラスのインスタンスに対して呼び
出す事を想定しています。Struct.new Struct の下位クラスを作成する点に
注意して...

Struct#length -> Integer (9044.0)

構造体のメンバの数を返します。

...の記述は Struct の下位クラスのインスタンスに対して呼び
出す事を想定しています。Struct.new Struct の下位クラスを作成する点に
注意してください。

//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Smith...

Array#pack(template, buffer: String.new) -> String (114.0)

配列の内容を template で指定された文字列にしたがって、 バイナリとしてパックした文字列を返します。

...'socket'
official_hostname, alias_hostnames, address_family, *address_list = Socket.gethostbyname("localhost")
address_list.find {|address| address.size == 4 }.unpack("C4").join(".")
# => "127.0.0.1"

"127.0.0.1".split(".").collect {|c| c.to_i}.pack("C4")
# => "\x7F\x00\x00\x01"
//}

: sockaddr_in...
...x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00".unpack("p") # => [nil]
//}

: 構造体のアドレス

例えば、
//emlist{
struct
{
int a;
short b;
long c;
} v = {1,2,3};
//}
を表す文字列は
//emlist[][ruby]{
v = [1,2,3].pack("i!s!...

Array#pack(template) -> String (14.0)

配列の内容を template で指定された文字列にしたがって、 バイナリとしてパックした文字列を返します。

...'socket'
official_hostname, alias_hostnames, address_family, *address_list = Socket.gethostbyname("localhost")
address_list.find {|address| address.size == 4 }.unpack("C4").join(".")
# => "127.0.0.1"

"127.0.0.1".split(".").collect {|c| c.to_i}.pack("C4")
# => "\x7F\x00\x00\x01"
//}

: sockaddr_in...
...x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00".unpack("p") # => [nil]
//}

: 構造体のアドレス

例えば、
//emlist{
struct
{
int a;
short b;
long c;
} v = {1,2,3};
//}
を表す文字列は
//emlist[][ruby]{
v = [1,2,3].pack("i!s!...

絞り込み条件を変える