48件ヒット
[1-48件を表示]
(0.035秒)
別のキーワード
検索結果
先頭4件
-
Psych
:: Visitors :: YAMLTree . new(options = {} , emitter = Psych :: TreeBuilder . new , ss = Psych :: ScalarScanner . new) -> Psych :: Visitors :: YAMLTree (18316.0) -
YAMLTree オブジェクトを生成します。
...設定されるオプション設定を指定します。
Psych.dump と同じオプションが指定できます。
emitter には AST の構築に使われる Psych::TreeBuilder オブジェクト
を渡します。
ss は Ruby の String が YAML document 上で quote が必要かどうか
を... -
Psych
. dump(o , io , options = {}) -> () (18185.0) -
Ruby のオブジェクト o を YAML ドキュメントに変換します。
...Ruby のオブジェクト o を YAML ドキュメントに変換します。
io に IO オブジェクトを指定した場合は、変換されたドキュメントが
その IO に書き込まれます。
指定しなかった場合は変換されたドキュメントが文字列としてメソ......ション
//emlist[例][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 (18185.0) -
Ruby のオブジェクト o を YAML ドキュメントに変換します。
...Ruby のオブジェクト o を YAML ドキュメントに変換します。
io に IO オブジェクトを指定した場合は、変換されたドキュメントが
その IO に書き込まれます。
指定しなかった場合は変換されたドキュメントが文字列としてメソ......ション
//emlist[例][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)
//}... -
Object
. yaml _ tag(tag) -> () (43.0) -
クラスと tag の間を関連付けます。
... Ruby のオブジェクトに
変換したりその逆をしたりすることができます。
@param 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
#...