本文簡要介紹ruby語言中 Psych::Handler.scalar 的用法。
用法
scalar(value, anchor, tag, plain, quoted, style)
當找到標量 value 時調用。標量可能有 anchor 、 tag 、隱含 plain 或隱含 quoted
value 是標量的字符串值 anchor 是關聯錨點或 nil tag 是關聯標簽或 nil plain 是布爾值 quoted 是布爾值 style 是表示字符串樣式
有關style 的可能值,請參見 Psych::Nodes::Scalar 中的常量
示例
這是一個 YAML 文檔,其中練習了可以調用此方法的大多數可能方式:
--- - !str "foo" - &anchor fun - many lines - | many newlines
上麵的 YAML 文檔包含一個包含四個字符串的列表。以下是按相同順序發送到此方法的參數:
# value anchor tag plain quoted style
["foo", nil, "!str", false, false, 3 ]
["fun", "anchor", nil, true, false, 1 ]
["many lines", nil, nil, true, false, 1 ]
["many\nnewlines\n", nil, nil, false, true, 4 ]
相關用法
- Ruby Handler.start_sequence用法及代碼示例
- Ruby Handler.start_mapping用法及代碼示例
- Ruby Handler.start_document用法及代碼示例
- Ruby Handler.end_document用法及代碼示例
- Ruby Handler.alias用法及代碼示例
- Ruby Handle類用法及代碼示例
- Ruby Handle.new用法及代碼示例
- Ruby Hash.reject用法及代碼示例
- Ruby Hash shift()用法及代碼示例
- Ruby Hash.delete()用法及代碼示例
- Ruby Hash length()用法及代碼示例
- Ruby Hash.new用法及代碼示例
- Ruby Hash.size用法及代碼示例
- Ruby Hash rehash用法及代碼示例
- Ruby Hash.delete用法及代碼示例
- Ruby Hash.hash <=用法及代碼示例
- Ruby Hash size()用法及代碼示例
- Ruby Hash each_pair()用法及代碼示例
- Ruby Hash.select!用法及代碼示例
- Ruby Hash value?用法及代碼示例
- Ruby Hash values用法及代碼示例
- Ruby Hash.ruby2_keywords_hash用法及代碼示例
- Ruby Hash.rassoc(obj)用法及代碼示例
- Ruby Hash.to_s用法及代碼示例
- Ruby Hash.values_at()用法及代碼示例
注:本文由純淨天空篩選整理自ruby-lang.org大神的英文原創作品 Handler.scalar。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
