Skip to content

Commit

Permalink
feat(Psych.load): サンプルコードを追従
Browse files Browse the repository at this point in the history
  • Loading branch information
nishidayuya committed May 5, 2024
1 parent 7f8b1c9 commit 7db02dd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions refm/api/src/psych.rd
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ filename はパース中に発生した例外のメッセージに用います
@raise Psych::SyntaxError YAMLドキュメントに文法エラーが発見されたときに発生します
@see [[m:Psych.parse]]

#@if("2.6.0" <= version)
#@samplecode 例
Psych.load("--- a") # => 'a'
Psych.load("---\n - a\n - b") # => ['a', 'b']

begin
Psych.load("--- `", filename: "file.txt")
rescue Psych::SyntaxError => ex
p ex.file # => 'file.txt'
p ex.message # => "(file.txt): found character that cannot start any token while scanning for the next token at line 1 column 5"
end
#@else
#@samplecode 例
Psych.load("--- a") # => 'a'
Psych.load("---\n - a\n - b") # => ['a', 'b']
Expand Down

0 comments on commit 7db02dd

Please sign in to comment.