るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

キーワード

検索結果

<< 1 2 3 > >>

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

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

...を 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>'
//}...

Object#to_s -> String (18256.0)

オブジェクトの文字列表現を返します。

...列表現を返します。

Kernel.#print や Kernel.#sprintf は文字列以外の
オブジェクトが引数に渡された場合このメソッドを使って文字列に変換し
ます。

//emlist[][ruby]{
class Foo
def initialize num
@
num = num
end

end

it = Foo.new(40)

puts it #=>...
...#<Foo:0x2b69110>

class Foo
def to_s
"Class:Foo Number:#{@num}"
end

end


puts it #=> Class:Foo Number:40
//}

@
see Object#to_str,Kernel.#String...

Method#to_s -> String (15304.0)

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

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

//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...
...# スーパークラスのクラスメソッド
class Bar < Foo
end

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

# 以下は(形式1)の出力になる
module Baz
def baz
end

end


class <<obj
include Baz
end

p obj.method(:baz) # => #<Method: Object(Baz)#baz>
//}

@
see Object#inspect...
...self を読みやすい文字列として返します。

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

#<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...

Module#to_s -> String (15250.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::...
...B.name #=> "A::B"
p A::C.name #=> "A::C"

# 名前のないモジュール / クラス
p Module.new.name #=> nil
p Class.new.name #=> nil
p Module.new.to_s #=> "#<Module:0x00007f90b09112c8>"
p Class.new.to_s #=> "#<Class:0x00007fa5c40b41b0>"
//}...

Digest::Base#to_s -> String (15238.0)

updateや<<によって追加した文字列に対するハッシュ値を、 ASCIIコードを使って16進数の列を示す文字列にエンコードして返します。

...イト長、SHA1およびRMD160では40バイト長、SHA256では64バイト長、
SHA384では96バイト長、SHA512では128バイト長です。

Ruby
で書くと以下と同じです。

def hexdigest
digest.unpack("H*")[0]
end


例:

# MD5の場合
r
equire 'digest/md5'
digest =...
...Digest::MD5.new
digest.update("ruby")
p digest.hexdigest # => "58e53d1324eef6265fdb97b08ed9aadf"

@
see Digest::Base#digest...

絞り込み条件を変える

Object#to_str -> String (12237.0)

オブジェクトの String への暗黙の変換が必要なときに内部で呼ばれます。 デフォルトでは定義されていません。

...オブジェクトの String への暗黙の変換が必要なときに内部で呼ばれます。
デフォルトでは定義されていません。

説明のためここに記載してありますが、
このメソッドは実際には Object クラスには定義されていません。
...
...面で代置可能であるような、
* 文字列そのものとみなせるようなもの
という厳しいものになっています。

//emlist[][ruby]{
class Foo
def to_str
'Edition'
end

end


it = Foo.new
p('Second' + it) #=> "SecondEdition"
//}

@
see Object#to_s,Kernel.#String...

IO#syswrite(string) -> Integer (6253.0)

write(2) を用いて string を出力します。 string が文字列でなければ to_s による文字列化を試みます。 実際に出力できたバイト数を返します。

...write(2) を用いて string を出力します。
string が文字列でなければ to_s による文字列化を試みます。
実際に出力できたバイト数を返します。

stdio を経由しないので他の出力メソッドと混用すると思わぬ動作
をすることがあり...
...ます。

@
param string 自身に書き込みたい文字列を指定します。

@
raise IOError 自身が書き込み用にオープンされていなければ発生します。

@
raise Errno::EXXX 出力に失敗した場合に発生します。

//emlist[例][ruby]{
File.open("testfile", "w+")...
...do |f|
f.syswrite("ABCDE") # => 5
f.syswrite(:ABC) # => 3
end

File.read("testfile") # => "ABCDEABC"
//}...

WIN32OLE_EVENT#handler=(obj) -> () (6173.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などの呼び出しでブロックが登録されている場
合、そちらが優先されます。...

IO#write(*str) -> Integer (6171.0)

IOポートに対して str を出力します。str が文字列でなけ れば to_s による文字列化を試みます。 実際に出力できたバイト数を返します。

...IOポートに対して str を出力します。str が文字列でなけ
れば to_s による文字列化を試みます。
実際に出力できたバイト数を返します。

IO#syswrite を除く全ての出力メソッドは、最終的に
"write" という名のメソッドを呼び出...
...とができます。

@
param str 自身に書き込みたい文字列を指定します。

@
raise IOError 自身が書き込み用にオープンされていなければ発生します。

@
raise Errno::EXXX 出力に失敗した場合に発生します。

//emlist[例][ruby]{
File.open("textfile...
...", "w+") do |f|
f.write("This is") # => 7
end

File.read("textfile") # => "This is"
//}
//emlist[複数引数の例][ruby]{
File.open("textfile", "w+") do |f|
f.write("This is", " a test\n") # => 15
end

File.read("textfile") # => "This is a test\n"
//}...
<< 1 2 3 > >>