Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Psych.loadの引数filenameの追従 #2870

Merged
merged 4 commits into from
May 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions refm/api/src/psych.rd
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,13 @@ libyaml のバージョンを返します。

@see [[m:Psych::LIBYAML_VERSION]]

#@since 2.5.0
#@if("2.6.0" <= version)
--- load(yaml, filename: nil, fallback: false, symbolize_names: false) -> object
#@end
#@if("2.5.0" <= version and version < "3.1")
--- load(yaml, filename = nil, fallback: false, symbolize_names: false) -> object
#@else
#@end
#@if(version < "2.5.0")
--- load(yaml, filename = nil, fallback = false) -> object
#@end

Expand All @@ -138,6 +142,19 @@ filename はパース中に発生した例外のメッセージに用います
@raise Psych::SyntaxError YAMLドキュメントに文法エラーが発見されたときに発生します
@see [[m:Psych.parse]]

#@since 2.6.0
#@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
#@end
#@else
#@samplecode 例
Psych.load("--- a") # => 'a'
Psych.load("---\n - a\n - b") # => ['a', 'b']
Expand All @@ -149,6 +166,7 @@ rescue Psych::SyntaxError => ex
p ex.message # => "(file.txt): found character that cannot start any token while scanning for the next token at line 1 column 5"
end
#@end
#@end

キーワード引数 symbolize_names に true を指定した場合はハッシュのキー
を [[c:Symbol]] に変換して返します。
Expand Down
Loading