Ruby 1.8.7 リファレンスマニュアル > ライブラリ一覧 > yaml/rubytypesライブラリ > Stringクラス > is_complex_yaml?

instance method String#is_complex_yaml?

is_complex_yaml? -> Integer | nil [added by yaml/rubytypes]

自身が複数行になるキーを含むような YAML である場合に真になる値を返しま す。

例: ["Detroit Tigers", "Chicago cubs"] をキーとする場合

require 'yaml'
s = <<EOS
?
  - Detroit Tigers
  - Chicago cubs
:
  - 2001-07-23
EOS
p s.is_complex_yaml? # => 2
p YAML.load(s) # => {["Detroit Tigers", "Chicago cubs"]=>[#<Date: 4904227/2,0,2299161>]}
class String