96件ヒット
[1-96件を表示]
(0.041秒)
種類
- インスタンスメソッド (74)
- 特異メソッド (22)
クラス
- Array (19)
-
RubyVM
:: InstructionSequence (33) - String (11)
- Struct (33)
検索結果
先頭5件
-
Struct
# size -> Integer (36127.0) -
構造体のメンバの数を返します。
...注意] 本メソッドの記述は Struct の下位クラスのインスタンスに対して呼び
出す事を想定しています。Struct.new は Struct の下位クラスを作成する点に
注意してください。
//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
joe =... -
Struct
# [](member) -> object (21044.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 (21027.0) -
構造体のメンバの数を返します。
...注意] 本メソッドの記述は Struct の下位クラスのインスタンスに対して呼び
出す事を想定しています。Struct.new は Struct の下位クラスを作成する点に
注意してください。
//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
joe =... -
RubyVM
:: InstructionSequence # to _ a -> Array (3026.0) -
self の情報を 14 要素の配列にして返します。
...ます。
命令シーケンスを以下の情報で表します。
: magic
データフォーマットを示す文字列。常に
"YARVInstructionSequence/SimpleDataFormat"。
: major_version
命令シーケンスのメジャーバージョン。
: minor_version
命令シーケンス......。常に 1。
: misc
以下の要素から構成される Hash オブジェクト。
:arg_size: メソッド、ブロックが取る引数の総数(1 つもない場合は 0)。
:local_size: ローカル変数の総数 + 1。
:stack_max: スタックの深さ。(SystemStackError......。
//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,... -
RubyVM
:: InstructionSequence . disasm(body) -> String (3008.0) -
引数 body で指定したオブジェクトから作成した RubyVM::InstructionSequence オブジェクトを人間が読める形式の文字 列に変換して返します。
...::InstructionSequence オブジェクトを人間が読める形式の文字
列に変換して返します。
@param body Proc、Method オブジェクトを指定します。
例1:Proc オブジェクトを指定した場合
# /tmp/proc.rb
p = proc { num = 1 + 2 }
puts RubyVM::Instruction......byVM::InstructionSequence:block in <main>@/tmp/proc.rb>===
== catch table
| catch type: redo st: 0000 ed: 0012 sp: 0000 cont: 0000
| catch type: next st: 0000 ed: 0012 sp: 0000 cont: 0012
|------------------------------------------------------------------------
local table (size: 2, ar......クトを指定した場合
# /tmp/method.rb
def hello
puts "hello, world"
end
puts RubyVM::InstructionSequence.disasm(method(:hello))
出力:
== disasm: <RubyVM::InstructionSequence:hello@/tmp/method.rb>============
0000 trace 8... -
RubyVM
:: InstructionSequence . disassemble(body) -> String (3008.0) -
引数 body で指定したオブジェクトから作成した RubyVM::InstructionSequence オブジェクトを人間が読める形式の文字 列に変換して返します。
...::InstructionSequence オブジェクトを人間が読める形式の文字
列に変換して返します。
@param body Proc、Method オブジェクトを指定します。
例1:Proc オブジェクトを指定した場合
# /tmp/proc.rb
p = proc { num = 1 + 2 }
puts RubyVM::Instruction......byVM::InstructionSequence:block in <main>@/tmp/proc.rb>===
== catch table
| catch type: redo st: 0000 ed: 0012 sp: 0000 cont: 0000
| catch type: next st: 0000 ed: 0012 sp: 0000 cont: 0012
|------------------------------------------------------------------------
local table (size: 2, ar......クトを指定した場合
# /tmp/method.rb
def hello
puts "hello, world"
end
puts RubyVM::InstructionSequence.disasm(method(:hello))
出力:
== disasm: <RubyVM::InstructionSequence:hello@/tmp/method.rb>============
0000 trace 8... -
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!... -
Array
# pack(template , buffer: String . new) -> 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!... -
String
# unpack(template) -> Array (14.0) -
Array#pack で生成された文字列を テンプレート文字列 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!...