るりまサーチ

最速Rubyリファレンスマニュアル検索!
404件ヒット [1-100件を表示] (0.286秒)
トップページ > クエリ:_builtin[x] > クエリ:puts[x] > 種類:特異メソッド[x]

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

クラス

モジュール

オブジェクト

キーワード

検索結果

<< 1 2 3 ... > >>

RubyVM::InstructionSequence.disasm(body) -> String (8025.0)

引数 body で指定したオブジェクトから作成した RubyVM::InstructionSequence オブジェクトを人間が読める形式の文字 列に変換して返します。

...oc、Method オブジェクトを指定します。

例1:Proc オブジェクトを指定した場合

# /tmp/proc.rb
p = proc { num = 1 + 2 }
puts
RubyVM::InstructionSequence.disasm(p)

出力:

== disasm: <RubyVM::InstructionSequence:block in <main>@/tmp/proc.rb>===
== catch table
| c...
...up
0009 setlocal num, 0
0012 leave

例2:Method オブジェクトを指定した場合

# /tmp/method.rb
def hello
puts
"hello, world"
end

puts
RubyVM::InstructionSequence.disasm(method(:hello))

出力:

== disasm: <RubyVM::InstructionSequence:hello@/tmp/method.rb>======...
...( 1)
0002 trace 1 ( 2)
0004 putself
0005 putstring "hello, world"
0007 send :puts, 1, nil, 8, <ic:0>
0013 trace 16 ( 3)
0015 leave...

RubyVM::InstructionSequence.disassemble(body) -> String (8025.0)

引数 body で指定したオブジェクトから作成した RubyVM::InstructionSequence オブジェクトを人間が読める形式の文字 列に変換して返します。

...oc、Method オブジェクトを指定します。

例1:Proc オブジェクトを指定した場合

# /tmp/proc.rb
p = proc { num = 1 + 2 }
puts
RubyVM::InstructionSequence.disasm(p)

出力:

== disasm: <RubyVM::InstructionSequence:block in <main>@/tmp/proc.rb>===
== catch table
| c...
...up
0009 setlocal num, 0
0012 leave

例2:Method オブジェクトを指定した場合

# /tmp/method.rb
def hello
puts
"hello, world"
end

puts
RubyVM::InstructionSequence.disasm(method(:hello))

出力:

== disasm: <RubyVM::InstructionSequence:hello@/tmp/method.rb>======...
...( 1)
0002 trace 1 ( 2)
0004 putself
0005 putstring "hello, world"
0007 send :puts, 1, nil, 8, <ic:0>
0013 trace 16 ( 3)
0015 leave...

IO.popen("-", mode = "r", opt={}) -> IO (8021.0)

第一引数に文字列 "-" が指定された時、fork(2) を 行い子プロセスの標準入出力との間にパイプラインを確立します。 親プロセスでは IO オブジェクトを返し、子プロセスでは nil を返します。

...ロセスでは IO オブジェクトを返し、子プロセスでは
nil を返します。

io = IO.popen("-", "r+")
if io # parent
io.puts "foo"
p io.gets # => "child output: foo\n"
io.close
else # child
s = gets
print "child output: " + s
exit...
...引数にブロックを実行し終了します。

p IO.popen("-", "r+") {|io|
if io # parent
io.puts "foo"
io.gets
else # child
s = gets
puts
"child output: " + s
end
}
# => "child output: foo\n"

opt ではエンコーディングの設定やプ...

IO.popen("-", mode = "r", opt={}) {|io| ... } -> object (8021.0)

第一引数に文字列 "-" が指定された時、fork(2) を 行い子プロセスの標準入出力との間にパイプラインを確立します。 親プロセスでは IO オブジェクトを返し、子プロセスでは nil を返します。

...ロセスでは IO オブジェクトを返し、子プロセスでは
nil を返します。

io = IO.popen("-", "r+")
if io # parent
io.puts "foo"
p io.gets # => "child output: foo\n"
io.close
else # child
s = gets
print "child output: " + s
exit...
...引数にブロックを実行し終了します。

p IO.popen("-", "r+") {|io|
if io # parent
io.puts "foo"
io.gets
else # child
s = gets
puts
"child output: " + s
end
}
# => "child output: foo\n"

opt ではエンコーディングの設定やプ...

IO.popen(env, "-", mode = "r", opt={}) -> IO (8021.0)

第一引数に文字列 "-" が指定された時、fork(2) を 行い子プロセスの標準入出力との間にパイプラインを確立します。 親プロセスでは IO オブジェクトを返し、子プロセスでは nil を返します。

...ロセスでは IO オブジェクトを返し、子プロセスでは
nil を返します。

io = IO.popen("-", "r+")
if io # parent
io.puts "foo"
p io.gets # => "child output: foo\n"
io.close
else # child
s = gets
print "child output: " + s
exit...
...引数にブロックを実行し終了します。

p IO.popen("-", "r+") {|io|
if io # parent
io.puts "foo"
io.gets
else # child
s = gets
puts
"child output: " + s
end
}
# => "child output: foo\n"

opt ではエンコーディングの設定やプ...

絞り込み条件を変える

IO.popen(env, "-", mode = "r", opt={}) {|io| ... } -> object (8021.0)

第一引数に文字列 "-" が指定された時、fork(2) を 行い子プロセスの標準入出力との間にパイプラインを確立します。 親プロセスでは IO オブジェクトを返し、子プロセスでは nil を返します。

...ロセスでは IO オブジェクトを返し、子プロセスでは
nil を返します。

io = IO.popen("-", "r+")
if io # parent
io.puts "foo"
p io.gets # => "child output: foo\n"
io.close
else # child
s = gets
print "child output: " + s
exit...
...引数にブロックを実行し終了します。

p IO.popen("-", "r+") {|io|
if io # parent
io.puts "foo"
io.gets
else # child
s = gets
puts
"child output: " + s
end
}
# => "child output: foo\n"

opt ではエンコーディングの設定やプ...

IO.binwrite(path, string, offset=nil) -> Integer (8019.0)

path で指定されるファイルを開き、string を書き込み、 閉じます。

...: どの環境でも同じ。
puts
png[0...16].unpack('C*').map {|c| '%02x' % c }.join(' ')
# => 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52

# binwriteを使用した場合: どの環境でも正しく保存できる。
IO.binwrite('white.binmode.png', png)
puts
IO.binread('white.binmode.png',...
...用しなかった場合: Windowsで改行文字(0x0a: "\n")と同じビット列が変換されてしまう。
IO.write('white.txtmode.png', png)
puts
IO.binread('white.txtmode.png', 16).unpack('C*').map {|c| '%02x' % c }.join(' ')
# => 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 (Linux/Macの...

Range.new(first, last, exclude_end = false) -> Range (8019.0)

first から last までの範囲オブジェクトを生成して返しま す。

...oday, Date.today >> 1).each {|d| puts d }
# => 2017-09-16
# 2017-09-17
# ...
# 2017-10-16
//}

//emlist[例: IPアドレスの範囲オブジェクトの場合][ruby]{
require 'ipaddr'
Range.new(IPAddr.new("192.0.2.1"), IPAddr.new("192.0.2.3")).each {|ip| puts ip}
# => 192.0.2.1
# 192.0....
...のオブジェクトの場合][ruby]{
MyInteger = Struct.new(:value) do
def succ
self.class.new(value + 1)
end

def <=>(other)
value <=> other.value
end

def to_s
value.to_s
end
end
Range.new(MyInteger.new(1), MyInteger.new(3)).each {|i| puts i }
# => 1
# 2
# 3
//}...

IO.popen([env = {}, [cmdname, arg0], *args, execopt={}], mode = "r", opt={}) -> IO (8016.0)

サブプロセスを実行し、そのプロセスの標準入出力 との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。

...を確立します。生成したパイプを IO オブジェクトとして返します。

p io = IO.popen("cat", "r+") # => #<IO:fd 4>
io.puts "foo"
io.close_write
p io.gets # => "foo\n"

サブプロセスを指定する方法は2通りあります。文字列を指...
...返します。ブロックの実行後、生成したパイ
プは自動的にクローズされます。

p IO.popen("cat", "r+") {|io|
io.puts "foo"
io.close_write
io.gets
}
# => "foo\n"


opt でプロセス起動のためのオプションや、パイプ IO オブジェクト...

IO.popen([env = {}, [cmdname, arg0], *args, execopt={}], mode = "r", opt={}) {|f| ... } -> object (8016.0)

サブプロセスを実行し、そのプロセスの標準入出力 との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。

...を確立します。生成したパイプを IO オブジェクトとして返します。

p io = IO.popen("cat", "r+") # => #<IO:fd 4>
io.puts "foo"
io.close_write
p io.gets # => "foo\n"

サブプロセスを指定する方法は2通りあります。文字列を指...
...返します。ブロックの実行後、生成したパイ
プは自動的にクローズされます。

p IO.popen("cat", "r+") {|io|
io.puts "foo"
io.close_write
io.gets
}
# => "foo\n"


opt でプロセス起動のためのオプションや、パイプ IO オブジェクト...

絞り込み条件を変える

<< 1 2 3 ... > >>