るりまサーチ (Ruby 2.6.0)

最速Rubyリファレンスマニュアル検索!
3件ヒット [1-3件を表示] (0.056秒)
トップページ > バージョン:2.6.0[x] > クエリ:IO[x] > クエリ:u[x] > モジュール:Psych[x]

別のキーワード

  1. io popen
  2. io pipe
  3. io each
  4. io each_line
  5. io readlines

ライブラリ

キーワード

検索結果

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

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

...[例][ruby]{
# Dump an array, get back a YAML 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 indentation set
Psych
.dump(['a', ['b']], StringIO.new, :indentation => 3)
//}...

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

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

...[例][ruby]{
# Dump an array, get back a YAML 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 indentation set
Psych
.dump(['a', ['b']], StringIO.new, :indentation => 3)
//}...

Psych.parse(yaml, filename = nil) -> Psych::Nodes::Document (322.0)

YAML ドキュメントをパースし、YAML の AST を返します。

...用います。

AST については Psych::Nodes を参照してください。

@param yaml YAML ドキュメント(文字列 or IO オブジェクト)
@param filename Psych::SyntaxError 発生時にファイル名として表示する文字列。
@raise Psych::SyntaxError YAMLドキュメント...
...に文法エラーが発見されたときに発生します
@see Psych.load

//emlist[例][ruby]{
Psych
.parse("---\n - a\n - b") # => #<Psych::Nodes::Document:...>

begin
Psych
.parse("--- `", "file.txt")
rescue Psych::SyntaxError => ex
p ex.file # => 'file.txt'
p ex.message # => "(file.txt...