るりまサーチ

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin each

ライブラリ

クラス

モジュール

オブジェクト

キーワード

検索結果

<< < 1 2 3 4 ... > >>

NameError#to_s -> String (26107.0)

例外オブジェクトを文字列に変換して返します。

...オブジェクトを文字列に変換して返します。

例:

begin
foobar
rescue NameError => err
p err # => #<NameError: undefined local variable or method `foobar' for main:Object>
p err.to_s # => "undefined local variable or method `foobar' for main:Object"
end...

NilClass#to_s -> String (26107.0)

空文字列 "" を返します。

...空文字列 "" を返します。

//emlist[例][ruby]{
nil.to_s # => ""
//}...

Object#to_s -> String (26107.0)

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

...使って文字列に変換し
ます。

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

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

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

...mlist[例][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>'
//}...

TrueClass#to_s -> String (26107.0)

常に文字列 "true" を返します。

...常に文字列 "true" を返します。

//emlist[例][ruby]{
true.to_s # => "true"
//}...

絞り込み条件を変える

UncaughtThrowError#to_s -> String (26107.0)

self を tag を含む文字列表現にして返します。

...self を tag を含む文字列表現にして返します。

//emlist[例][ruby]{
def do_complicated_things
throw :uncaught_label
end

begin
do_complicated_things
rescue UncaughtThrowError => ex
p ex.to_s # => "uncaught throw :uncaught_label"
end
//}...

Fixnum#to_s(base = 10) -> String (23137.0)

self を引数で指定した基数の文字列表現に変換します。

...列表現に変換します。

@param base 基数を 2 から 36 の整数で指定します。

12345.to_s #=> "12345"
12345.to_s(2) #=> "11000000111001"
12345.to_s(8) #=> "30071"
12345.to_s(10) #=> "12345"
12345.to_s(16) #=> "3039"
12345.to_s(36) #=> "9ix"...

Float#to_s -> String (23137.0)

自身を人間が読みやすい形の文字列表現にして返します。

...列を返します。

//emlist[例][ruby]{
0.00001.to_s # => "1.0e-05"
3.14.to_s # => "3.14"
10000_00000_00000.0.to_s # => "100000000000000.0"
10000_00000_00000_00000.0.to_s # => "1.0e+19"
(1.0/0.0).to_s # => "Infinity"
(0.0/0.0).to_s # => "NaN"
//}...

Bignum#to_s(base = 10) -> String (23131.0)

self を引数で指定した基数の文字列表現に変換します。

...を 2 から 36 の整数で指定します。

12345654321.to_s #=> "12345654321"
12345654321.to_s(2) #=> "1011011111110110111011110000110001"
12345654321.to_s(8) #=> "133766736061"
12345654321.to_s(16) #=> "2dfdbbc31"
78546939656932.to_s(36) #=> "rubyrules"...

Integer#to_s(base=10) -> String (23125.0)

整数を 10 進文字列表現に変換します。

...を指定すれば、それを基数とした文字列表
現に変換します。

//emlist[][ruby]{
p 10.to_s(2) # => "1010"
p 10.to_s(8) # => "12"
p 10.to_s(16) # => "a"
p 35.to_s(36) # => "z"
//}

@return 数値の文字列表現
@param base 基数となる 2 - 36 の数値。
@rai...

絞り込み条件を変える

Module#to_s -> String (23113.0)

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

...lass 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>"
//}...
<< < 1 2 3 4 ... > >>