414件ヒット
[301-400件を表示]
(0.084秒)
別のキーワード
ライブラリ
- ビルトイン (210)
-
json
/ add / exception (12) - logger (12)
-
net
/ http (36) - optparse (12)
- pathname (48)
- rake (24)
-
rake
/ packagetask (12) -
rexml
/ document (24) -
rubygems
/ gem _ path _ searcher (12) - win32ole (12)
クラス
-
ARGF
. class (24) - Dir (24)
- Exception (24)
- File (24)
-
Gem
:: GemPathSearcher (12) - IO (6)
- Logger (12)
-
Net
:: HTTPGenericRequest (12) -
Net
:: HTTPResponse (24) - OptionParser (12)
- Pathname (48)
- Proc (12)
-
REXML
:: Element (24) -
Rake
:: Application (12) -
Rake
:: FileList (12) -
Rake
:: PackageTask (12) -
RubyVM
:: InstructionSequence (36) -
Thread
:: Backtrace :: Location (48) - TracePoint (24)
-
WIN32OLE
_ TYPELIB (12)
キーワード
-
absolute
_ path (24) - binread (12)
- filename (12)
- formatter (12)
- inspect (36)
-
lib
_ dirs _ for (12) -
original
_ dir (12) -
package
_ dir _ path (12) - pathmap (12)
-
program
_ name (12) -
read
_ body (24) -
set
_ backtrace (12) -
source
_ location (12) - sub (24)
- text (12)
-
to
_ json (12) -
to
_ path (27) -
to
_ s (24) - xpath (12)
検索結果
先頭5件
-
Proc
# source _ location -> [String , Integer] | nil (245.0) -
ソースコードのファイル名と行番号を配列で返します。
...ジェクトが ruby で定義されていない(つまりネイティブ
である)場合は nil を返します。
//emlist[例][ruby]{
# /path/to/target.rb を実行
proc {}.source_location # => ["/path/to/target.rb", 1]
proc {}.source_location # => ["/path/to/target.rb",... -
Thread
:: Backtrace :: Location # inspect -> String (233.0) -
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).locations.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 `... -
Thread
:: Backtrace :: Location # to _ s -> String (233.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 `<main... -
Exception
# to _ json(*args) -> String (227.0) -
自身を JSON 形式の文字列に変換して返します。
...orMethods::Hash#to_json に渡されます。
//emlist[例][ruby]{
require "json/add/core"
begin
0/0
rescue => e
e.to_json # => "{\"json_class\":\"ZeroDivisionError\",\"m\":\"divided by 0\",\"b\":[\"/path/to/test.rb:4:in `/'\",\"/path/to/test.rb:4:in `<main>'\"]}"
end
//}
@see JSON::Generator... -
Logger
# formatter -> String (221.0) -
ログを出力する際に使用するフォーマッターを取得します。
...ソッドの返り値が持つ call メソッドは 4 つの引数 (severity, time, program name, message) を受けとります。
//emlist[例][ruby]{
require 'logger'
logger = Logger.new(STDOUT)
logger.formatter # => nil
logger.info("test")
# => I, [2019-05-09T22:13:56.509159 #13912] INFO -- :......g|
"time:#{timestamp}\tlevel:#{severity}\tprogname:#{progname}\tmessage:#{msg}\n"
}
logger.formatter = ltsv_formatter
logger.formatter # => #<Proc:0x00007fa3048b8e00@/path/to/file:8>
logger.info("MyApp") { "test" }
# => time:2019-05-09 22:13:56 +0900 level:INFO progname:MyApp message:test
//}... -
OptionParser
# program _ name -> String (221.0) -
プログラムの名前を文字列で返します。
...字列で返します。
デフォルトは $0 が使われます。
@return プログラムの名前を文字列で返します。
//emlist[例][ruby]{
require "optparse"
OptionParser.new do |opts|
p $0 # => /path/to/filename.rb
p opts.program_name # => filename
end
//}... -
Rake
:: Application # original _ dir -> String (221.0) -
rake コマンドを実行したディレクトリを返します。
...rake コマンドを実行したディレクトリを返します。
//emlist[][ruby]{
# Rakefile での記載例とする
task default: :test_rake_app
task :test_rake_app do
Rake.application.original_dir # => "/path/to/dir"
end
//}... -
TracePoint
# inspect -> String (221.0) -
self の状態を人間に読みやすい文字列にして返します。
...self の状態を人間に読みやすい文字列にして返します。
//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:call) do |tp|
p tp.inspect # "#<TracePoint:call `foo'@/path/to/test.rb:1>"
end
trace.enable
foo 1
//}... -
ARGF
. class # filename -> String (218.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...