このマニュアルは既にメンテナンスが終了したバージョンの Ruby を対象としています。 最新版のマニュアルへ

Ruby 1.8.7 リファレンスマニュアル

instance method String#is_complex_yaml?

is_complex_yaml? -> Integer | nil[permalink][rdoc] [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>]}