ライブラリ
- ビルトイン (296)
-
irb
/ inspector (12) - socket (60)
クラス
- Data (6)
- Dir (24)
-
IRB
:: Inspector (12) - Proc (14)
-
RubyVM
:: InstructionSequence (36) - Socket (60)
- Struct (48)
- Thread (42)
オブジェクト
- main (126)
キーワード
- [] (20)
-
compile
_ file (12) -
def
_ inspector (12) - define (6)
-
define
_ method (24) - disasm (12)
- disassemble (12)
- gethostbyname (12)
- glob (16)
- include (12)
- inspect (12)
- new (62)
- open (12)
- pair (12)
- pass (12)
- private (27)
- public (27)
-
report
_ on _ exception (9) -
report
_ on _ exception= (9) - socketpair (12)
-
to
_ s (12) - using (12)
検索結果
先頭5件
-
Socket
. gethostbyname(host) -> Array (19.0) -
ホスト名または IP アドレス(指定方法に関しては lib:socket#host_formatを参照) からホストの情報を返します。
....unpack_sockaddr_in で unpack できます。
=== 使用例
irb(main):009:0> require 'socket'
irb(main):009:0> Socket.gethostbyname("210.251.121.214")
["helium.ruby-lang.org", ["helium"], 2, "\322\373y\326"]
irb(main):009:0> Socket.unpack_sockaddr_in(Socket.gethostbyname("210.251.121.... -
Data
. define(*args) -> Class (7.0) -
Data クラスに新しいサブクラスを作って、それを返します。
...ます。
//emlist[例][ruby]{
Customer = Data.define(:name, :address) do
def greeting
"Hello #{name}!"
end
end
p Customer.new("Dave", "123 Main").greeting # => "Hello Dave!"
//}
なお、Dataのサブクラスのインスタンスを生成する際にオプション引数を使用した... -
Data
. define(*args) {|subclass| block } -> Class (7.0) -
Data クラスに新しいサブクラスを作って、それを返します。
...ます。
//emlist[例][ruby]{
Customer = Data.define(:name, :address) do
def greeting
"Hello #{name}!"
end
end
p Customer.new("Dave", "123 Main").greeting # => "Hello Dave!"
//}
なお、Dataのサブクラスのインスタンスを生成する際にオプション引数を使用した... -
Dir
. [](*pattern , base: nil) -> [String] (7.0) -
ワイルドカードの展開を行い、 パターンにマッチするファイル名を文字列の配列として返します。 パターンにマッチするファイルがない場合は空の配列を返します。
..."{b,f}*") #=> ["bar", "foo"]
# ベースディレクトリの例
rbfiles = File.join("**", "*.rb")
Dir.glob(rbfiles) #=> ["main.rb",
# "lib/song.rb",
# "lib/song/karaoke.rb"]
Dir.glob(rbfiles, base... -
Dir
. [](*pattern , base: nil , sort: true) -> [String] (7.0) -
ワイルドカードの展開を行い、 パターンにマッチするファイル名を文字列の配列として返します。 パターンにマッチするファイルがない場合は空の配列を返します。
..."{b,f}*") #=> ["bar", "foo"]
# ベースディレクトリの例
rbfiles = File.join("**", "*.rb")
Dir.glob(rbfiles) #=> ["main.rb",
# "lib/song.rb",
# "lib/song/karaoke.rb"]
Dir.glob(rbfiles, base... -
Dir
. glob(pattern , flags = 0 , base: nil) -> [String] (7.0) -
ワイルドカードの展開を行い、 パターンにマッチするファイル名を文字列の配列として返します。 パターンにマッチするファイルがない場合は空の配列を返します。
..."{b,f}*") #=> ["bar", "foo"]
# ベースディレクトリの例
rbfiles = File.join("**", "*.rb")
Dir.glob(rbfiles) #=> ["main.rb",
# "lib/song.rb",
# "lib/song/karaoke.rb"]
Dir.glob(rbfiles, base... -
Dir
. glob(pattern , flags = 0 , base: nil) {|file| . . . } -> nil (7.0) -
ワイルドカードの展開を行い、 パターンにマッチするファイル名を文字列の配列として返します。 パターンにマッチするファイルがない場合は空の配列を返します。
..."{b,f}*") #=> ["bar", "foo"]
# ベースディレクトリの例
rbfiles = File.join("**", "*.rb")
Dir.glob(rbfiles) #=> ["main.rb",
# "lib/song.rb",
# "lib/song/karaoke.rb"]
Dir.glob(rbfiles, base... -
Dir
. glob(pattern , flags = 0 , base: nil , sort: true) -> [String] (7.0) -
ワイルドカードの展開を行い、 パターンにマッチするファイル名を文字列の配列として返します。 パターンにマッチするファイルがない場合は空の配列を返します。
..."{b,f}*") #=> ["bar", "foo"]
# ベースディレクトリの例
rbfiles = File.join("**", "*.rb")
Dir.glob(rbfiles) #=> ["main.rb",
# "lib/song.rb",
# "lib/song/karaoke.rb"]
Dir.glob(rbfiles, base... -
Dir
. glob(pattern , flags = 0 , base: nil , sort: true) {|file| . . . } -> nil (7.0) -
ワイルドカードの展開を行い、 パターンにマッチするファイル名を文字列の配列として返します。 パターンにマッチするファイルがない場合は空の配列を返します。
..."{b,f}*") #=> ["bar", "foo"]
# ベースディレクトリの例
rbfiles = File.join("**", "*.rb")
Dir.glob(rbfiles) #=> ["main.rb",
# "lib/song.rb",
# "lib/song/karaoke.rb"]
Dir.glob(rbfiles, base... -
IRB
:: Inspector . def _ inspector(key , arg = nil) { |v| . . . } -> object (7.0) -
新しい実行結果の出力方式を定義します。
...ロックを指定しない場合には、実行結果の出力のための手続きオ
ブジェクトを指定します。
例.
# .irbrc
IRB::Inspector.def_inspector([:test]){ |v| v.to_s * 2 }
$ irb --inspect test
irb(main):001:0> :abc # => abcabc
@see lib:irb#inspect_mode... -
Proc
. new -> Proc (7.0) -
ブロックをコンテキストとともにオブジェクト化して返します。
...Proc.new
end
foo
# => -:2:in `new': tried to create Proc object without a block (ArgumentError)
# from -:2:in `foo'
# from -:4:in `<main>'
//}
Proc.new は、Proc#initialize が定義されていれば
オブジェクトの初期化のためにこれを呼び出します。このこ... -
Proc
. new { . . . } -> Proc (7.0) -
ブロックをコンテキストとともにオブジェクト化して返します。
...Proc.new
end
foo
# => -:2:in `new': tried to create Proc object without a block (ArgumentError)
# from -:2:in `foo'
# from -:4:in `<main>'
//}
Proc.new は、Proc#initialize が定義されていれば
オブジェクトの初期化のためにこれを呼び出します。このこ... -
RubyVM
:: InstructionSequence . compile _ file(file , options = nil) -> RubyVM :: InstructionSequence (7.0) -
引数 file で指定した Ruby のソースコードを元にコンパイル済みの RubyVM::InstructionSequence オブジェクトを作成して返します。
...yVM::InstructionSequence.compile_option= を参照
してください。
# /tmp/hello.rb
puts "Hello, world!"
# irb
RubyVM::InstructionSequence.compile_file("/tmp/hello.rb")
# => <RubyVM::InstructionSequence:<main>@/tmp/hello.rb>
@see RubyVM::InstructionSequence.compile... -
RubyVM
:: InstructionSequence . disasm(body) -> String (7.0) -
引数 body で指定したオブジェクトから作成した RubyVM::InstructionSequence オブジェクトを人間が読める形式の文字 列に変換して返します。
.../tmp/proc.rb
p = proc { num = 1 + 2 }
puts RubyVM::InstructionSequence.disasm(p)
出力:
== disasm: <RubyVM::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 c... -
RubyVM
:: InstructionSequence . disassemble(body) -> String (7.0) -
引数 body で指定したオブジェクトから作成した RubyVM::InstructionSequence オブジェクトを人間が読める形式の文字 列に変換して返します。
.../tmp/proc.rb
p = proc { num = 1 + 2 }
puts RubyVM::InstructionSequence.disasm(p)
出力:
== disasm: <RubyVM::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 c...