るりまサーチ

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

別のキーワード

  1. fiddle ruby_free
  2. rbconfig ruby
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

RubyVM::InstructionSequence#base_label -> String (32131.0)

self が表す命令シーケンスの基本ラベルを返します。

...1:irb で実行した場合

iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>
iseq.base_label
# => "<compiled>"

例2: RubyVM::InstructionSequence.compile_file を使用した場合

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


# irb
> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
> iseq.base_label # => "<main>"

例3:

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


Ruby
VM::InstructionSequence.of(method(:hello)).base_label
# => "hello"

@
see RubyVM::Instructio...

RubyVM::InstructionSequence#label -> String (32131.0)

self が表す命令シーケンスのラベルを返します。通常、メソッド名、クラス名、 モジュール名などで構成されます。

...rb で実行した場合

iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>
iseq.label
# => "<compiled>"

例2: RubyVM::InstructionSequence.compile_file を使用した場合

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


# irb
> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
> iseq.label # => "<main>"

例3:

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


Ruby
VM::InstructionSequence.of(method(:hello)).label
# => "hello"

@
see RubyVM::InstructionSequence#base_la...

RubyVM::InstructionSequence#absolute_path -> String | nil (32119.0)

self が表す命令シーケンスの絶対パスを返します。

...irb で実行した場合

iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>
iseq.absolute_path
# => nil

例2: RubyVM::InstructionSequence.compile_file を使用した場合

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


# irb
> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
> iseq.absolute_path # => "/tmp/method.rb"

@
see RubyVM::InstructionSequence#path...

RubyVM::InstructionSequence#path -> String (32119.0)

self が表す命令シーケンスの相対パスを返します。

...irb で実行した場合

iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>
iseq.path
# => "<compiled>"

例2: RubyVM::InstructionSequence.compile_file を使用した場合

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


# irb
> iseq = RubyVM::InstructionSequence.compile_file('method.rb')
> iseq.path # => "method.rb"

@
see RubyVM::InstructionSequence#absolute_path...

CSV#puts(row) -> self (15250.0)

自身に row を追加します。

...自身に row を追加します。

データソースは書き込み用にオープンされていなければなりません。

@
param row 配列か CSV::Row のインスタンスを指定します。
CSV::Row のインスタンスが指定された場合は、CSV::Row#fields の値...
...列を指定][ruby]{
r
equire "csv"

File.write("test.csv", <<CSV)
id,first name,last name,age
1,taro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
CSV
CSV.open("test.csv", "a") do |csv|
csv.puts(["5", "saburo", "kondo", "34"])
end


print File.read("test.csv")
# => id,first name,last na...
...me,age
# 1,taro,tanaka,20
# 2,jiro,suzuki,18
# 3,ami,sato,19
# 4,yumi,adachi,21
# 5,saburo,kondo,34
//}

//emlist[例 CSV::Row を指定][ruby]{
r
equire "csv"

File.write("test.csv", <<CSV)
id,first name,last name,age
1,taro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
CS...

絞り込み条件を変える

Net::HTTP#send_request(name, path, data = nil, header = nil) -> Net::HTTPResponse (12349.0)

HTTP リクエストをサーバに送り、そのレスポンスを Net::HTTPResponse のインスタンスとして返します。

...Net::HTTPResponse のインスタンスとして返します。

@
param name リクエストのメソッド名を文字列で与えます。
@
param path リクエストのパスを文字列で与えます。
@
param data リクエストのボディを文字列で与えます。
@
param header リク...
...エストのヘッダをハッシュで与えます。

//emlist[例][ruby]{
r
esponse = http.send_request('GET', '/index.html')
puts
response.body
//}

@
see Net::HTTP#request...

Module#prepend(*modules) -> self (12309.0)

指定したモジュールを self の継承チェインの先頭に「追加する」ことで self の定数、メソッド、モジュール変数を「上書き」します。

...義されたメソッドは
override されます。

modules で指定したモジュールは後ろから順に処理されるため、
modules の先頭が最も優先されます。

また、継承によってこの「上書き」を処理するため、prependの引数として
渡したモジ...
...スタンスメソッドでsuperを呼ぶことで
self のモジュール/クラスのメソッドを呼び出すことができます。

実際の処理は modules の各要素の prepend_features を後ろから順に呼びだすだけです。
Module#prepend_features が継承チェインの改...
...、prepend_features を override することで
prepend の処理を追加/変更できます。


@
param modules prepend する Module を指定します
@
see Module#prepend_features, Module#prepended

//emlist[例][ruby]{
# super と prepend の組み合わせの例
module X
def foo
puts
"X...

Module#prepended(class_or_module) -> () (12249.0)

self が Module#prepend されたときに対象のクラスまたはモジュールを 引数にしてインタプリタがこのメソッドを呼び出します。

...repend されたときに対象のクラスまたはモジュールを
引数にしてインタプリタがこのメソッドを呼び出します。

@
param class_or_module Module#prepend を実行したオブジェクト

//emlist[例][ruby]{
module A
def self.prepended(mod)
puts
"#{self} pr...
...epended to #{mod}"
end

end

module Enumerable
prepend A
end

# => "A prepended to Enumerable"
//}

@
see Module#included, Module#prepend, Module#prepend_features...

Encoding::InvalidByteSequenceError#error_bytes -> String (9137.0)

エラー発生時に捨てられたバイト列を返します。

...st[例][ruby]{
ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
begin
ec.convert("abc\xA1\xFFdef")
r
escue Encoding::InvalidByteSequenceError
p $!
#=> #<Encoding::InvalidByteSequenceError: "\xA1" followed by "\xFF" on EUC-JP>
puts
$!.error_bytes.dump #=> "\xA1"
puts
$!.readagai...
...n_bytes.dump #=> "\xFF"
end

//}

@
see Encoding::InvalidByteSequenceError#readagain_bytes...
<< 1 2 3 ... > >>