るりまサーチ

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

別のキーワード

  1. _builtin to_r
  2. string []=
  3. string slice!
  4. string []
  5. string slice

ライブラリ

キーワード

検索結果

<< 1 2 > >>

Rational#to_s -> String (30433.0)

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

..."-17/7" のように10進数の表記を返します。

@return 有理数の表記にした文字列を返します。

//emlist[例][ruby]{
R
ational(3, 4).to_s # => "3/4"
R
ational(8).to_s # => "8/1"
R
ational(-8, 6).to_s # => "-4/3"
R
ational(0.5).to_s # => "1/2"
//}

@see Rational#inspect...

Gem::Version#to_s -> String (30416.0)

バージョン情報を文字列として返します。

...バージョン情報を文字列として返します。

//emlist[][ruby]{
version = Gem::Version.new("1.2.3a")
p version.to_s # => "1.2.3a"
p version.version # => "1.2.3a"
//}...

Rake::InvocationChain#to_s -> String (30415.0)

トップレベルのタスクから自身までの依存関係を文字列として返します。

...の依存関係を文字列として返します。

//emlist[][ruby]{
# Rakefile での記載例とする

t
ask default: :test_rake_app
t
ask :test_rake_app do
invocation_chain= Rake::InvocationChain.new("task_a", Rake::InvocationChain::EMPTY)
invocation_chain.to_s # => "TOP => task_a"
end
//}...

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

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

...ernel.#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 `initi...
...alize'
# path/to/foo.rb:9:in `new'
# path/to/foo.rb:9:in `<main>'
//}...

JSON::Generator::GeneratorMethods::Object#to_json(state_or_hash = nil) -> String (27424.0)

自身を to_s で文字列にした結果を JSON 形式の文字列に変換して返します。

...自身を to_s で文字列にした結果を JSON 形式の文字列に変換して返します。

このメソッドはあるオブジェクトに to_json メソッドが定義されていない場合に使用する
フォールバックのためのメソッドです。

@param state_or_hash 生...
...する JSON 形式の文字列をカスタマイズするため
に JSON::State のインスタンスか、
JSON::State.new の引数と同じ Hash を
指定します。

//emlist[例][ruby]{
r
equire "json"

class Person
attr :name, :...
...age

def initialize(name, age)
@name, @age = name, age
end
end

t
anaka = Person.new("tanaka", 29)

t
anaka.to_json # => "\"#<Person:0x00007ffdec0167c8>\""
t
anaka.method(:to_json).owner # => JSON::Ext::Generator::GeneratorMethods::Object
//}...

絞り込み条件を変える

OptionParser#to_s -> String (27416.0)

サマリの文字列を返します。

...emlist[例][ruby]{
r
equire "optparse"

options = {}
opts = OptionParser.new do |opts|
opts.banner = "Usage: example.rb [options]"

opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
options[:verbose] = v
end
end

puts opts.help

# => Usage: example.rb [options]
# -v, --[no-]verbose...
...Run verbosely
//}...

Exception#to_s -> String (24416.0)

エラーメッセージをあらわす文字列を返します。

...エラーメッセージをあらわす文字列を返します。

//emlist[例][ruby]{
begin
1 + nil
r
escue => e
p e.message #=> "nil can't be coerced into Fixnum"
end
//}...

CSV::Table#to_s(options = Hash.new) -> String (21510.0)

CSV の文字列に変換して返します。

...オプションに :write_headers =>
false を指定するとヘッダを出力しません。

//emlist[][ruby]{
r
equire 'csv'
csv = CSV.new("a,b,c\n1,2,3", headers: true)
t
able = csv.read
p table.to_csv # => "a,b,c\n1,2,3\n"
p table.to_csv(write_headers: false) # => "1,2,3\n"...

Gem::Version#version -> String (18416.0)

バージョン情報を文字列として返します。

...バージョン情報を文字列として返します。

//emlist[][ruby]{
version = Gem::Version.new("1.2.3a")
p version.to_s # => "1.2.3a"
p version.version # => "1.2.3a"
//}...
<< 1 2 > >>