るりまサーチ

最速Rubyリファレンスマニュアル検索!
162件ヒット [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 > >>

ARGF.class#read(length = nil, str = nil) -> String | nil (21262.0)

ARGVに指定されたファイルを先頭のファイルからlengthバイト読み込み、 その文字列をstrに出力します。読み込んだ文字列を返します。

...イルからlengthバイト読み込み、
その文字列をstrに出力します。読み込んだ文字列を返します。

@
param length 読み込むバイト数を指定します。nilの場合はARGVのすべてのファ
イルを読み込みます。

@
param str 出力先の...
...文字列。内容は上書きされます。

$ echo "small" > small.txt
$ echo "large" > large.txt
$ ruby glark.rb small.txt large.txt

ARGF.read # => "small\nlarge"
ARGF.read(200) # => "small\nlarge"
ARGF.read(2) # => "sm"
ARGF.read(0) # => ""

@
see IO#read...

ARGF.class#readbyte -> Integer (15319.0)

自身から 1 バイトを読み込み整数として返します。 既に EOF に達していれば EOFError が発生します。

...EOFError が発生します。

@
raise EOFError 既に EOF に達している場合に発生します。

$ echo "foo" > file
$ ruby argf.rb file

ARGF.readbyte # => 102
ARGF.readbyte # => 111
ARGF.readbyte # => 111
ARGF.readbyte # => 10
ARGF.readbyte # => end of file reached (EO...

IO#readbyte -> Integer (12325.0)

IO から1バイトを読み込み整数として返します。 既に EOF に達していれば EOFError が発生します。

...

@
raise EOFError 既に EOF に達している場合に発生します。

//emlist[例][ruby]{
IO.write("testfile", "123")
File.open("testfile") do |f|
begin
f.readbyte # => 49
f.readbyte # => 50
f.readbyte # => 51
f.readbyte # => 例外発生
rescue => e
e.class # =...

Module#attr_reader(*name) -> [Symbol] (12249.0)

インスタンス変数 name の読み取りメソッドを定義します。

.../emlist[例][ruby]{
class
User
attr_reader :name # => [:name]
# 複数の名前を渡すこともできる
attr_reader :id, :age # => [:id, :age]
end
//}

このメソッドで定義されるメソッドの定義は以下の通りです。

//emlist[例][ruby]{
def name
@
name
end
//}

@
param...
...name String または Symbol を 1 つ以上指定します。
@
return 定義されたメソッド名を Symbol の配列で返します。...

Thread::Backtrace::Location#absolute_path -> String (12131.0)

self が表すフレームの絶対パスを返します。

...list[例][ruby]{
# foo.rb
class
Foo
attr_accessor :locations
def initialize(skip)
@
locations = caller_locations(skip)
end
end

Foo.new(0..2).locations.map do |call|
puts call.absolute_path
end

# => /path/to/foo.rb
# /path/to/foo.rb
# /path/to/foo.rb
//}

@
see Thread::Backtrace::Location...
...#path...

絞り込み条件を変える

ARGF.class#readchar -> String (9231.0)

ARGFから 1 文字読み込んで、その文字に対応する String を返します。EOF に 到達した時には EOFErrorを発生します。

...String を返します。EOF に
到達した時には EOFErrorを発生します。

@
raise EOFError EOFに達した時発生する

$ echo "foo" > file
$ ruby argf.rb file

ARGF.readchar # => "f"
ARGF.readchar # => "o"
ARGF.readchar # => "o"
ARGF.readchar # => "\n"
ARGF.readchar...
...# => end of file reached (EOFError)

@
see ARGF.class#getc...

Thread#add_trace_func(pr) -> Proc (9149.0)

スレッドにトレース用ハンドラを追加します。

...

@
param pr トレースハンドラ(Proc オブジェクト)

//emlist[例][ruby]{
t
h = Thread.new do
class
Trace
end
43.to_s
end
t
h.add_trace_func lambda {|*arg| p arg }
t
h.join

# => ["line", "example.rb", 4, nil, #<Binding:0x00007f98e107d0d8>, nil]
# => ["c-call", "example.rb", 4, :inherit...
...ed, #<Binding:0x00007f98e1087448>, Class]
# => ["c-return", "example.rb", 4, :inherited, #<Binding:0x00007f98e1085d00>, Class]
# => ["class", "example.rb", 4, nil, #<Binding:0x00007f98e108f210>, nil]
# => ["end", "example.rb", 5, nil, #<Binding:0x00007f98e108e5e0>, nil]
# => ["line", "example.rb", 6...
..., nil, #<Binding:0x00007f98e108d4b0>, nil]
# => ["c-call", "example.rb", 6, :to_s, #<Binding:0x00007f98e1097aa0>, Integer]
# => ["c-return", "example.rb", 6, :to_s, #<Binding:0x00007f98e1095cc8>, Integer]
//}

@
see Thread#set_trace_func Kernel.#set_trace_func...

Thread#set_trace_func(pr) -> Proc | nil (9149.0)

スレッドにトレース用ハンドラを設定します。

...

//emlist[例][ruby]{
t
h = Thread.new do
class
Trace
end
2.to_s
T
hread.current.set_trace_func nil
3.to_s
end
t
h.set_trace_func lambda {|*arg| p arg }
t
h.join

# => ["line", "example.rb", 2, nil, #<Binding:0x00007fc8de87cb08>, nil]
# => ["c-call", "example.rb", 2, :inherited, #<Binding:...
...0x00007fc8de886770>, Class]
# => ["c-return", "example.rb", 2, :inherited, #<Binding:0x00007fc8de8844e8>, Class]
# => ["class", "example.rb", 2, nil, #<Binding:0x00007fc8de88e830>, nil]
# => ["end", "example.rb", 3, nil, #<Binding:0x00007fc8de88d6b0>, nil]
# => ["line", "example.rb", 4, nil, #<Bindi...
..., :to_s, #<Binding:0x00007fc8de896f30>, Integer]
# => ["c-return", "example.rb", 4, :to_s, #<Binding:0x00007fc8de894a50>, Integer]
# => ["line", "example.rb", 5, nil, #<Binding:0x00007fc8de967b08>, nil]
# => ["c-call", "example.rb", 5, :current, #<Binding:0x00007fc8de967798>, Thread]
# => ["c-return...

Thread::Backtrace::Location#inspect -> String (9125.0)

Thread::Backtrace::Location#to_s の結果を人間が読みやすいような文 字列に変換したオブジェクトを返します。

...
T
hread::Backtrace::Location#to_s の結果を人間が読みやすいような文
字列に変換したオブジェクトを返します。

//emlist[例][ruby]{
# foo.rb
class
Foo
attr_accessor :locations
def initialize(skip)
@
locations = caller_locations(skip)
end
end

Foo.new(0..2).loc...
...ations.map do |call|
puts call.inspect
end

# => "path/to/foo.rb:5:in `initialize'"
# "path/to/foo.rb:9:in `new'"
# "path/to/foo.rb:9:in `<main>'"
//}...
<< 1 2 > >>