るりまサーチ

最速Rubyリファレンスマニュアル検索!
2854件ヒット [1-100件を表示] (0.040秒)
トップページ > クエリ:tr[x] > クエリ:to_s[x]

別のキーワード

  1. _builtin to_s
  2. openssl to_der
  3. openssl to_s
  4. _builtin to_a
  5. openssl to_pem

クラス

オブジェクト

キーワード

検索結果

<< 1 2 3 ... > >>

tracer (26006.0)

実行トレース出力をとる機能を提供します。

...ruby -rtracer hoge.rb

もうひとつはソースからrequireする方法です。

require 'tracer'

とした後

Tr
acer.on

によりトレース出力を有効にします。

Tr
acer.off

によりトレース出力を無効にします。

また、ブロック付きで Tracer.on...
...tracer'

class Hoge
def Hoge.fuga(i)
"fuga #{i}"
end
end

Tr
acer.add_filter {|event, file, line, id, binding, klass|
event =~ /line/ and klass.to_s =~ /hoge/i
}
Tr
acer.on
for i in 0..3
puts Hoge.fuga(i) if i % 3 == 0
end
Tr
acer.off

=== SEE ALSO

Kernel.#set_tr...

String#to_s -> String (21225.0)

self を返します。

...[ruby]{
p "str".to_s # => "str"
p "str".to_str # => "str"
//}

このメソッドは、文字列を他のクラスのインスタンスと混ぜて処理したいときに有効です。
例えば返り値が文字列か nil であるメソッド some_method があるとき、
to_s
メソッ...
...ドを使うと以下のように統一的に処理できます。

//emlist[例][ruby]{
# some_method(5).downcase だと返り値が nil のときに
# エラーになるので to_s をはさむ
p some_method(5).to_s.downcase
//}...

Matrix#to_s -> String (21207.0)

行列を文字列化し、その文字列を返します。

...行列を文字列化し、その文字列を返します。

//emlist[例][ruby]{
require 'matrix'
a1 = [1, 2]
a2 = [3, 4.5]
m = Matrix[a1, a2]

p m.to_s # => "Matrix[[1, 2], [3, 4.5]]"
//}...

Thread::Backtrace::Location#to_s -> String (21207.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'
# p...

TrueClass#to_s -> String (21207.0)

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

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

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

絞り込み条件を変える

REXML::Attribute#to_s -> String (21201.0)

正規化された属性値を返します。

正規化された属性値を返します。

属性値の正規化については XML の仕様を参考にしてください。

Scanf::FormatString#to_s (21101.0)

@todo

@todo

OpenSSL::BN#to_s(base=10) -> String (18285.0)

自身を表す文字列を返します。

...p 10.to_bn.to_s # => "10"
p (-5).to_bn.to_s # => "-5"

p 0.to_bn.to_s(16) # => "0"
p 9.to_bn.to_s(16) # => "09"
p 10.to_bn.to_s(16) # => "0A"
p 16.to_bn.to_s(16) # => "10"
p 26.to_bn.to_s(16) # => "1A"
p 256.to_bn.to_s(16) # => "0100"

p 0.to_bn.to_s(2) # => ""
p 6.to_bn.to_s(2) # => "\...
...x06"
p 7.to_bn.to_s(2) # => "\a"

p 0.to_bn.to_s(0) # => "\x00\x00\x00\x00"
p 6.to_bn.to_s(0) # => "\x00\x00\x00\x01\x06"
p 7.to_bn.to_s(0) # => "\x00\x00\x00\x01\a"
//}

反対に、文字列から OpenSSL::BN クラスのインスタンスを作るには
OpenSSL::BN.new を用います。

@see Op...

BigDecimal#to_s -> String (18262.0)

self を文字列に変換します (デフォルトは "0.xxxxxen" の形になります)。

...フォルトは "0.xxxxxen" の形になります)。

@param n 出力の形式を Integer または String で指定します。

//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").to_s # ==> "0.123456e1"
//}

引数 n に正の整数が指定されたときは、小数点で分けら...
...decimal"
BigDecimal("0.1234567890123456789").to_s(10) # => "0.1234567890 123456789e0"
//}

引数 n に正の整数を表す文字列を指定することもできます。

//emlist[][ruby]{
require "bigdecimal"
BigDecimal("0.1234567890123456789").to_s("10") # => "0.1234567890 123456789e0"
//}...
...常に '-' が付きます。

//emlist[][ruby]{
require "bigdecimal"
BigDecimal("0.123456").to_s(" 3") # => " 0.123 456e0"
BigDecimal("0.123456").to_s("+3") # => "+0.123 456e0"
BigDecimal("-0.123456").to_s("3") # => "-0.123 456e0"
//}

さらに文字列の最後に指数形式 ('E' または 'e')...
<< 1 2 3 ... > >>