112件ヒット
[1-100件を表示]
(0.159秒)
別のキーワード
ライブラリ
- ビルトイン (112)
クラス
-
ARGF
. class (48) - Module (4)
- Thread (12)
-
Thread
:: Backtrace :: Location (48)
キーワード
-
absolute
_ path (12) -
attr
_ reader (4) - backtrace (12)
-
base
_ label (12) - filename (12)
- inspect (12)
- path (12)
- readchar (12)
-
to
_ s (12)
検索結果
先頭5件
-
ARGF
. class # read(length = nil , str = nil) -> String | nil (21345.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... -
Module
# attr _ reader(*name) -> [Symbol] (12237.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 (12220.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 (9336.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
# backtrace -> [String] | nil (9320.0) -
スレッドの現在のバックトレースを返します。
...ist[例][ruby]{
class C1
def m1
sleep 5
end
def m2
m1
end
end
th = Thread.new {C1.new.m2; Thread.stop}
th.backtrace
# => [
# [0] "(irb):3:in `sleep'",
# [1] "(irb):3:in `m1'",
# [2] "(irb):6:in `m2'",
# [3] "(irb):10:in `block in irb_binding'"
# ]
th.kill
th.......backtrace # => nil
//}... -
Thread
:: Backtrace :: Location # inspect -> String (9220.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......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>'"
//}... -
Thread
:: Backtrace :: Location # to _ s -> String (9220.0) -
self が表すフレームを 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
# => path/to/foo.rb:5:in `initialize'
# path/to/foo.rb:9:in `new'
# path/to/foo.rb:9:in `<m... -
ARGF
. class # path -> String (6221.0) -
現在開いている処理対象のファイル名を返します。
...は - を返します。
組み込み変数 $FILENAME と同じです。
$ echo "foo" > foo
$ echo "bar" > bar
$ echo "glark" > glark
$ ruby argf.rb foo bar glark
ARGF.filename # => "foo"
ARGF.read(5) # => "foo\nb"
ARGF.filename # => "bar"
ARGF.skip
ARGF.filename # => "glark"... -
Thread
:: Backtrace :: Location # base _ label -> String (6220.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.ba......se_label
end
# => initialize
# new
# <main>
//}
@see Thread::Backtrace::Location#label...