るりまサーチ

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

別のキーワード

  1. string []=
  2. string slice!
  3. string slice
  4. string []
  5. string gsub!

ライブラリ

キーワード

検索結果

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

ARGVに指定されたファイルを先頭のファイルから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#readchar -> String (9365.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...

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

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

...[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 (3233.0)

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

...//emlist[例][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::Lo...

Thread::Backtrace::Location#base_label -> String (3233.0)

self が表すフレームの基本ラベルを返します。通常、 Thread::Backtrace::Location#label から修飾を取り除いたもので構成 されます。

...ームの基本ラベルを返します。通常、
Thread::Backtrace::Location#label から修飾を取り除いたもので構成
されます。

//emlist[例][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.base_label
end

# => initialize
# new
# <main>
//}

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

絞り込み条件を変える

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

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

...Thread::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...

Thread::Backtrace::Location#to_s -> String (3227.0)

self が表すフレームを Kernel.#caller と同じ表現にした文字列を返し ます。

...f が表すフレームを Kernel.#caller と同じ表現にした文字列を返し
ます。

//emlist[例][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.to_s
end

# =...