1110件ヒット
[1-100件を表示]
(0.136秒)
ライブラリ
- ビルトイン (728)
- bigdecimal (24)
- csv (48)
- digest (24)
- erb (12)
- json (12)
- matrix (24)
- openssl (12)
- optparse (24)
- pathname (24)
- rake (24)
-
rexml
/ document (96) -
rubygems
/ requirement (12) -
rubygems
/ version (24) - set (10)
- stringio (12)
クラス
- Array (36)
- BigDecimal (24)
-
CSV
:: Row (24) -
CSV
:: Table (24) - Complex (12)
- Data (6)
-
Digest
:: Base (24) - ERB (12)
- Encoding (24)
- Exception (24)
- FalseClass (24)
- Float (24)
-
Gem
:: Requirement (12) -
Gem
:: Version (24) - Hash (24)
- IO (12)
- Integer (24)
- MatchData (12)
- Matrix (12)
- Method (24)
- Module (36)
- NilClass (12)
- Object (78)
-
OpenSSL
:: BN (12) - OptionParser (24)
- Pathname (24)
- Proc (24)
-
REXML
:: Attribute (12) -
REXML
:: CData (24) -
REXML
:: DocType (12) -
REXML
:: Element (12) -
REXML
:: Entity (12) -
REXML
:: Text (24) -
Rake
:: FileList (12) -
Rake
:: InvocationChain (12) - Range (24)
- Rational (24)
- Regexp (24)
- Set (16)
- String (108)
- StringIO (12)
- Struct (24)
- Symbol (17)
- Thread (16)
-
Thread
:: Backtrace :: Location (24) - Time (18)
- TrueClass (12)
- UnboundMethod (24)
- UncaughtThrowError (11)
- Vector (12)
モジュール
キーワード
- % (12)
-
add
_ element (12) - binread (12)
-
define
_ singleton _ method (24) -
end
_ with? (6) - entities (12)
- help (12)
- hex (12)
- hexdigest (12)
- inspect (193)
- intern (12)
- join (12)
- name (29)
- oct (12)
- src (12)
-
start
_ with? (6) - syswrite (12)
- then (14)
-
to
_ csv (24) -
to
_ f (12) -
to
_ i (12) -
to
_ json (12) -
to
_ str (24) -
to
_ string (12) -
to
_ sym (12) - value (24)
- version (12)
- write (12)
-
yield
_ self (16)
検索結果
先頭5件
-
String
# to _ s -> String (33340.0) -
self を返します。
...list[例][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
//}... -
Vector
# to _ s -> String (27331.0) -
ベクトル(Vector)から文字列 (String) に変換します。
...ベクトル(Vector)から文字列 (String) に変換します。
//emlist[例][ruby]{
require 'matrix'
v = Vector[2, 3, 5, 7, 9]
p v.to_s
# => "Vector[2, 3, 5, 7, 9]"
//}... -
BigDecimal
# to _ s -> String (24401.0) -
self を文字列に変換します (デフォルトは "0.xxxxxen" の形になります)。
...nteger または String で指定します。
//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").to_s # ==> "0.123456e1"
//}
引数 n に正の整数が指定されたときは、小数点で分けられる左右部分を、
それぞれ n 桁毎に空白で区切ります。
//emlist......[][ruby]{
require "bigdecimal"
BigDecimal("0.1234567890123456789").to_s(10) # => "0.1234567890 123456789e0"
//}
引数 n に正の整数を表す文字列を指定することもできます。
//emlist[][ruby]{
require "bigdecimal"
BigDecimal("0.1234567890123456789").to_s("10") # => "0.12345678......きます。負の場合は常に '-' が付きます。
//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"
//}
さらに文字列の最後に指数... -
BigDecimal
# to _ s(n) -> String (24401.0) -
self を文字列に変換します (デフォルトは "0.xxxxxen" の形になります)。
...nteger または String で指定します。
//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").to_s # ==> "0.123456e1"
//}
引数 n に正の整数が指定されたときは、小数点で分けられる左右部分を、
それぞれ n 桁毎に空白で区切ります。
//emlist......[][ruby]{
require "bigdecimal"
BigDecimal("0.1234567890123456789").to_s(10) # => "0.1234567890 123456789e0"
//}
引数 n に正の整数を表す文字列を指定することもできます。
//emlist[][ruby]{
require "bigdecimal"
BigDecimal("0.1234567890123456789").to_s("10") # => "0.12345678......きます。負の場合は常に '-' が付きます。
//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"
//}
さらに文字列の最後に指数... -
OpenSSL
:: BN # to _ s(base=10) -> String (24393.0) -
自身を表す文字列を返します。
...mlist[][ruby]{
require 'openssl'
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::B... -
Time
# to _ s -> String (24351.0) -
時刻を文字列に変換した結果を返します。 以下のようにフォーマット文字列を使って strftime を呼び出すのと同じです。
...文字列を使って strftime を呼び出すのと同じです。
//emlist[][ruby]{
t = Time.local(2000,1,2,3,4,5,6)
p t.to_s # => "2000-01-02 03:04:05 +0900"
p t.strftime("%Y-%m-%d %H:%M:%S %z") # => "2000-01-02 03:04:05 +0900"
p t.utc.to_s......# => "2000-01-01 18:04:05 UTC"
p t.strftime("%Y-%m-%d %H:%M:%S UTC") # => "2000-01-01 18:04:05 UTC"
//}
戻り値の文字エンコーディングは Encoding::US_ASCII です。... -
Complex
# to _ s -> String (24339.0) -
自身を "実部 + 虚部i" 形式の文字列にして返します。
...ます。
//emlist[例][ruby]{
Complex(2).to_s # => "2+0i"
Complex('-8/6').to_s # => "-4/3+0i"
Complex('1/2i').to_s # => "0+1/2i"
Complex(0, Float::INFINITY).to_s # => "0+Infinity*i"
Complex(Float::NAN, Float::NAN).to_s # => "NaN+NaN*i"... -
Range
# to _ s -> String (24337.0) -
self を文字列に変換します(始端と終端のオブジェクトは #to_s メソッドで文 字列に変換されます)。
...self を文字列に変換します(始端と終端のオブジェクトは #to_s メソッドで文
字列に変換されます)。
@see Range#inspect
//emlist[例][ruby]{
(1..5).to_s # => "1..5"
("1".."5").to_s # => "1..5"
//}... -
REXML
:: Text # to _ s -> String (24333.0) -
テキストの内容を正規化(すべての実体をエスケープ)された状態で返します。
...トとして妥当です。
結果は REXML::Text.new で指定した entity_filter を反映しています。
@see REXML::Text#value
//emlist[][ruby]{
require 'rexml/document'
t = REXML::Text.new("< & foobar", false, nil, false)
t.to_s # => "< & foobar"
t.value # => "< & foobar"
//}...