るりまサーチ

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

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method new
  4. irb/input-method gets
  5. matrix -

検索結果

<< 1 2 3 ... > >>

String#dump -> String (24423.0)

文字列中の非表示文字をバックスラッシュ記法に置き換えた文字列を返します。 str == eval(str.dump) となることが保証されています。

...に置き換えた文字列を返します。
str == eval(str.dump) となることが保証されています。

//emlist[例][ruby]{
# p だとさらにバックスラッシュが増えて見にくいので puts している
puts "abc\r\n\f\x00\b10\\\"".dump # => "abc\r\n\f\x00\b10\\\""
//}...
...文字列を返します。
str == eval(str.dump) となることが保証されています。

//emlist[例][ruby]{
# p だとさらにバックスラッシュが増えて見にくいので puts している
puts "abc\r\n\f\x00\b10\\\"".dump # => "abc\r\n\f\x00\b10\\\""
//}

@see String#undump...

Psych.dump(o, io, options = {}) -> () (18580.0)

Ruby のオブジェクト o を YAML ドキュメントに変換します。

...変換します。

i
o に IO オブジェクトを指定した場合は、変換されたドキュメントが
その IO に書き込まれます。
指定しなかった場合は変換されたドキュメントが文字列としてメソッドの返り値と
なります。

options で出力に...
...ical
出力の style が canonical であるかどうかを真偽値で指定します
: :line_width
「好ましい」行幅を整数値で指定します

@param o 変換するオブジェクト
@param io 出力先
@param options 出力オプション

//emlist[例][ruby]{
# Dump an array, get...
...string
Psych.dump(['a', 'b']) # => "---\n- a\n- b\n"

# Dump an array to an IO object
Psych.dump(['a', 'b'], StringIO.new) # => #<StringIO:0x000001009d0890>

# Dump an array with indentation set
Psych.dump(['a', ['b']], :indentation => 3) # => "---\n- a\n- - b\n"

# Dump an array to an IO with in...

JSON.#dump(object, io = nil, limit = nil) -> String | IO (18525.0)

与えられたオブジェクトを JSON 形式の文字列に変換してダンプします。

...数として JSON.#generate を呼び出します。


@param object ダンプするオブジェクトを指定します。

@param io IO のように write メソッドを実装しているオブジェクトを指定します。

@param limit 指定した場合、limit 段以上深くリンクし...
...

@raise ArgumentError オブジェクトのネストの深さが limit を越えた場合に発生します。

//emlist[例][ruby]{
require "json"

JSON.dump({ name: "tanaka", age: 19 }) # => "{\"name\":\"tanaka\",\"age\":19}"
//}

//emlist[例][ruby]{
require "json"

File.open("test.txt", "w")...
...do |f|
JSON.dump([[[[[[[[[[]]]]]]]]]], f, 10) # => #<File:test.txt>
JSON.dump([[[[[[[[[[[]]]]]]]]]]], f, 10) # => exceed depth limit (ArgumentError)
end
//}

@see Marshal, Marshal.#dump...

Psych.dump(o, options = {}) -> String (18480.0)

Ruby のオブジェクト o を YAML ドキュメントに変換します。

...変換します。

i
o に IO オブジェクトを指定した場合は、変換されたドキュメントが
その IO に書き込まれます。
指定しなかった場合は変換されたドキュメントが文字列としてメソッドの返り値と
なります。

options で出力に...
...ical
出力の style が canonical であるかどうかを真偽値で指定します
: :line_width
「好ましい」行幅を整数値で指定します

@param o 変換するオブジェクト
@param io 出力先
@param options 出力オプション

//emlist[例][ruby]{
# Dump an array, get...
...string
Psych.dump(['a', 'b']) # => "---\n- a\n- b\n"

# Dump an array to an IO object
Psych.dump(['a', 'b'], StringIO.new) # => #<StringIO:0x000001009d0890>

# Dump an array with indentation set
Psych.dump(['a', ['b']], :indentation => 3) # => "---\n- a\n- - b\n"

# Dump an array to an IO with in...

Marshal.#dump(obj, limit = -1) -> String (18434.0)

obj を指定された出力先に再帰的に出力します。

...イルに書き出そうとすると
例外 TypeError が発生します。
ファイルに書き出せないオブジェクトは以下の通りです。

* 名前のついてない Class/Module オブジェクト。(この場
合は、例外 ArgumentError が発生します。無名クラス...
...を保持するもの。具体的には以下のイン
スタンス。Dir, File::Stat, IO とそのサブクラス
File, Socket など。
* MatchData, Data, Method, UnboundMethod,
Proc, Thread, ThreadGroup, Continuation
のインスタンス。
* 特異メソッドを定義したオブ...
...

//emlist[例][ruby]{
p Marshal.dump(Hash.new {})
# => -:1:in `dump': cannot dump hash with default proc (TypeError)
//}

マーシャルの動作を任意に定義することもできます。

@param obj ダンプする対象のオブジェクトを指定します。

@param port IO かその...

絞り込み条件を変える

Marshal.#dump(obj, port, limit = -1) -> IO (18434.0)

obj を指定された出力先に再帰的に出力します。

...イルに書き出そうとすると
例外 TypeError が発生します。
ファイルに書き出せないオブジェクトは以下の通りです。

* 名前のついてない Class/Module オブジェクト。(この場
合は、例外 ArgumentError が発生します。無名クラス...
...を保持するもの。具体的には以下のイン
スタンス。Dir, File::Stat, IO とそのサブクラス
File, Socket など。
* MatchData, Data, Method, UnboundMethod,
Proc, Thread, ThreadGroup, Continuation
のインスタンス。
* 特異メソッドを定義したオブ...
...

//emlist[例][ruby]{
p Marshal.dump(Hash.new {})
# => -:1:in `dump': cannot dump hash with default proc (TypeError)
//}

マーシャルの動作を任意に定義することもできます。

@param obj ダンプする対象のオブジェクトを指定します。

@param port IO かその...

Encoding::Converter#insert_output(string) -> nil (15520.0)

変換器内のバッファに文字列を挿入します。 バッファに保持された文字列は、次の変換時の変換結果と一緒に返されます。

...string 挿入する文字列

//emlist[][ruby]{
ec = Encoding::Converter.new("utf-8", "iso-8859-1")
src = "HIRAGANA LETTER A is \u{3042}."
dst = ""
p ec.primitive_convert(src, dst) #=> :undefined_conversion
puts "[#{dst.dump}, #{src.dump}]" #=> ["HIRAGANA LETTER A is ", "."]
ec.insert_output("...
....primitive_convert(src, dst) #=> :finished
puts "[#{dst.dump}, #{src.dump}]" #=> ["HIRAGANA LETTER A is <err>.", ""]

ec = Encoding::Converter.new("utf-8", "iso-2022-jp")
src = "\u{306F 3041 3068 2661 3002}" # U+2661 is not representable in iso-2022-jp
dst = ""
p ec.primitive_convert(src, dst)...
...#=> :undefined_conversion
puts "[#{dst.dump}, #{src.dump}]" #=> ["\e$B$O$!$H".force_encoding("ISO-2022-JP"), "\xE3\ x80\x82"]
ec.insert_output "?" # state change required to output "?".
p ec.primitive_convert(src, dst) #=> :finished
puts "[#{dst.dump}, #{src.dump}]" #=> [...

String#inspect -> String (15424.0)

文字列オブジェクトの内容を、出力したときに人間が読みやすいような適当な形式に変換します。 変換された文字列は印字可能な文字のみによって構成されます

...ために用意されています。
永続化などの目的で文字列をダンプしたいときは、
String#dump を使うべきです。

//emlist[例][ruby]{
# p ではないことに注意
puts "string".inspect # => "string"
puts "\t\r\n".inspect # => "\t\r\n"
//}

@see String#dump...

Encoding::InvalidByteSequenceError#error_bytes -> String (15336.0)

エラー発生時に捨てられたバイト列を返します。

...//emlist[例][ruby]{
ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
begin
ec.convert("abc\xA1\xFFdef")
rescue Encoding::InvalidByteSequenceError
p $!
#=> #<Encoding::InvalidByteSequenceError: "\xA1" followed by "\xFF" on EUC-JP>
puts $!.error_bytes.dump #=> "\xA1"
puts $!.r...
...eadagain_bytes.dump #=> "\xFF"
end
//}

@see Encoding::InvalidByteSequenceError#readagain_bytes...

Encoding::Converter#primitive_convert(source_buffer, destination_buffer, destination_byteoffset, destination_bytesize, options) -> Symbol (13024.0)

エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。

...oding::Converter#primitive_convert が唯一の方法になります。

@param source_buffer 変換元文字列のバッファ
@param destination_buffer 変換先文字列を格納するバッファ
@param destination_byteoffset 変換先バッファでのオフセット
@param destination_bytesize...
...coding::Converter::AFTER_OUTPUT

戻り値は以下のうちのどれかです。

* :invalid_byte_sequence
* :incomplete_input
* :undefined_conversion
* :after_output
* :destination_buffer_full
* :source_buffer_empty
* :finished

//emlist[][ruby]{
ec = Encoding::Converter.new("UTF-8",...
...UC-JP")
src = "abc\x81あいう\u{20bb7}\xe3"
dst = ''

begin
ret = ec.primitive_convert(src, dst)
p [ret, src, dst, ec.primitive_errinfo]
case ret
when :invalid_byte_sequence
ec.insert_output(ec.primitive_errinfo[3].dump[1..-2])
redo
when :undefined_conversion
c = ec.primitive...

絞り込み条件を変える

<< 1 2 3 ... > >>