るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

キーワード

検索結果

<< 1 2 > >>

Thread::Backtrace::Location#inspect -> String (21238.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>'"
//}...

TracePoint#inspect -> String (21232.0)

self の状態を人間に読みやすい文字列にして返します。

...self の状態を人間に読みやすい文字列にして返します。

//emlist[例][ruby]{
def foo(ret)
r
et
end

trace = TracePoint.new(:call) do |tp|
p tp.inspect # "#<TracePoint:call `foo'@/path/to/test.rb:1>"
end

trace.enable
foo 1
//}...

Method#inspect -> String (18316.0)

self を読みやすい文字列として返します。

...式の文字列を返します。

#<Method: klass1(klass2)#method> (形式1)

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクトの生成
元となったクラス/モジュール名です。

klass2...
...ソッド名を表します。

//emlist[例][ruby]{
module Foo
def foo
"foo"
end

end

class Bar
include Foo
def bar
end

end


p Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo>
p Bar.new.method(:bar) # => #<Method: Bar#bar>
//}

klass1 と klass2 が同じ場合は以下...
...トになります。

//emlist[例][ruby]{
# オブジェクトの特異メソッド
obj = ""
class <<obj
def foo
end

end

p obj.method(:foo) # => #<Method: "".foo>

# クラスメソッド(クラスの特異メソッド)
class Foo
def Foo.foo
end

end

p Foo.method(:foo) # => #<Meth...
...す。

以下の形式の文字列を返します。

#<Method: klass1(klass2)#method(arg) foo.rb:2> (形式1)

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクトの生成
元となったクラス/モジュー...
...します。

arg は引数を表します。
「foo.rb:2」は Method#source_location を表します。
source_location が nil の場合には付きません。

//emlist[例][ruby]{
module Foo
def foo
"foo"
end

end

class Bar
include Foo
def bar(a, b)
end

end


p Bar.new.method(:foo)...
...Bar(Foo)#foo() test.rb:2>
p Bar.new.method(:bar) # => #<Method: Bar#bar(a, b) test.rb:8>
//}

klass1 と klass2 が同じ場合は以下の形式になります。
#<Method: klass1#method() foo.rb:2> (形式2)

特異メソッドに対しては、
#<Method: obj.method() foo.rb...

Object#inspect -> String (18274.0)

オブジェクトを人間が読める形式に変換した文字列を返します。

...組み込み関数 Kernel.#p は、このメソッドの結果を使用して
オブジェクトを表示します。

//emlist[][ruby]{
[ 1, 2, 3..4, 'five' ].inspect # => "[1, 2, 3..4, \"five\"]"
Time.new.inspect # => "2008-03-08 19:43:39 +0900"
//}

inspect
メソッドをオ...
...変数の名前、値の組を元にした文字列を返します。

//emlist[][ruby]{
class Foo
end

Foo.new.inspect # => "#<Foo:0x0300c868>"

class Bar
def initialize
@bar = 1
end

end

Bar.new.inspect # => "#<Bar:0x0300c868 @bar=1>"
//}

@see Kernel.#p...

Module#inspect -> String (18232.0)

モジュールやクラスの名前を文字列で返します。

...が挙げられます。

@return 名前のないモジュール / クラスに対しては、name は nil を、それ以外はオブジェクト ID の文字列を返します。

//emlist[例][ruby]{
module A
module B
end


p B.name #=> "A::B"

class C
end

end


p A.name #=> "A"
p A::...

絞り込み条件を変える

Exception#inspect -> String (18226.0)

self のクラス名と message を文字列にして返します。

...self のクラス名と message を文字列にして返します。

//emlist[例][ruby]{
begin
r
aise "exception"
r
escue
p $!.inspect # => "#<RuntimeError: exception>"
end

//}...

WIN32OLE_EVENT#handler=(obj) -> () (6155.0)

イベント処理を実行するオブジェクトを登録します。

...@param obj イベントに対応するメソッドを持つオブジェクト。イベント受信を
解除するにはnilを指定します。

class IeHandler
def initialize
@completed = false
end

attr_reader :completed
def onDocumentComplete(disp, uri)...
...nerHTML}=#{e.href}"
end

@completed = true
end

def method_missing(id, *args)
puts "event=#{id.to_s}, args=#{args.inspect}"
end

end


ie = WIN32OLE.new('InternetExplorer.Application.1')
event = WIN32OLE_EVENT.new(ie, 'DWebBrowserEvents2')
event.handler = IeHandler....
...new
ie.Navigate2 'http://www.ruby-lang.org/ja/'
loop do
break if event.handler.completed
WIN32OLE_EVENT.message_loop
end

ie.Quit

WIN32OLE_EVENT#on_eventなどの呼び出しでブロックが登録されている場
合、そちらが優先されます。...

Object#pretty_print(pp) -> () (6131.0)

PP.pp や Kernel.#pp がオブジェクトの内容を出力するときに 呼ばれるメソッドです。PP オブジェクト pp を引数として呼ばれます。

...ernel.#pp がオブジェクトの内容を出力するときに
呼ばれるメソッドです。PP オブジェクト pp を引数として呼ばれます。

あるクラスの pp の出力をカスタマイズしたい場合は、このメソッドを再定義します。
そのとき pretty_pri...
...じめ pretty_print メソッドを定義しています。

@param pp PP オブジェクトです。

//emlist[][ruby]{
r
equire 'pp'

class Array
def pretty_print(q)
q.group(1, '[', ']') {
q.seplist(self) {|v|
q.pp v
}
}
end

end

//}

@see Object#pretty_print_cycle, O...
...bject#inspect, PrettyPrint#text, PrettyPrint#group, PrettyPrint#breakable...
...pretty_print メソッドを定義しています。

@param pp PP オブジェクトです。

//emlist[][ruby]{
class Array
def pretty_print(q)
q.group(1, '[', ']') {
q.seplist(self) {|v|
q.pp v
}
}
end

end

//}

@see Object#pretty_print_cycle, Object#inspect, Prett...
...yPrint#text, PrettyPrint#group, PrettyPrint#breakable...

String#%(args) -> String (3521.0)

printf と同じ規則に従って args をフォーマットします。

...printf と同じ規則に従って args をフォーマットします。

args が配列であれば Kernel.#sprintf(self, *args) と同じです。
それ以外の場合は Kernel.#sprintf(self, args) と同じです。

@param args フォーマットする値、もしくはその配列
@retur...
...n フォーマットされた文字列

//emlist[例][ruby]{
p "i = %d" % 10 # => "i = 10"
p "i = %x" % 10 # => "i = a"
p "i = %o" % 10 # => "i = 12"

p "i = %#d" % 10 # => "i = 10"
p "i = %#x" % 10 # => "i = 0xa"
p "i = %#o" % 10 # => "i = 012"

p "%d" % 10...
...2"
//}

=== sprintf フォーマット

Ruby
の sprintf フォーマットは基本的に C 言語の sprintf(3)
のものと同じです。ただし、short や long などの C 特有の型に対する修飾子が
ないこと、2進数の指示子(%b, %B)が存在すること、sprintf のすべ...
<< 1 2 > >>