るりまサーチ

最速Rubyリファレンスマニュアル検索!
19件ヒット [1-19件を表示] (0.009秒)
トップページ > ライブラリ:psych[x] > クエリ:yaml_as[x]

別のキーワード

  1. yaml/dbm select
  2. psych to_yaml
  3. yaml/store new
  4. yaml yaml
  5. psych yaml_tag

クラス

キーワード

検索結果

Module#yaml_as(tag) -> () (18104.0)

クラスと tag の間を関連付けます。

クラスと tag の間を関連付けます。

これによって tag 付けされた YAML ドキュメントを Ruby のオブジェクトに
変換したりその逆をしたりすることができます。

この method は deprecated です。 Object.yaml_tag を
かわりに使ってください。

@param tag 対象のクラスに関連付けるタグの文字列

Module#psych_yaml_as(tag) -> () (6104.0)

クラスと tag の間を関連付けます。

クラスと tag の間を関連付けます。

これによって tag 付けされた YAML ドキュメントを Ruby のオブジェクトに
変換したりその逆をしたりすることができます。

この method は deprecated です。 Object.yaml_tag を
かわりに使ってください。

@param tag 対象のクラスに関連付けるタグの文字列

Object.yaml_tag(tag) -> () (8.0)

クラスと tag の間を関連付けます。

...=== Example
require 'psych'

class Foo
def initialize(x)
@x = x
end

attr_reader :x
end

# Dumps Ruby object normally
p Psych.dump(Foo.new(3))
# =>
# --- !ruby/object:Foo
# x: 3

# Registers tag with class Foo
Foo.yaml_as("tag:example.com,2013:foo")...
...# ... and dumps the object of Foo class
Psych
.dump(Foo.new(3), STDOUT)
# =>
# --- !<tag:example.com,2013:foo>
# x: 3

# Loads the object from the tagged YAML node
p Psych.load(<<EOS)
--- !<tag:example.com,2012:foo>
x: 8
EOS
# => #<Foo:0x0000000130f48 @x=8>...