Skip to content

Commit

Permalink
Merge pull request #2870 from nishidayuya/follow_psych_load_argument_…
Browse files Browse the repository at this point in the history
…change

Psych.loadの引数filenameの追従
  • Loading branch information
znz authored May 9, 2024
2 parents 80c2852 + 0acb12d commit e00d53b
Showing 1 changed file with 20 additions and 2 deletions.
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

0 comments on commit e00d53b

Please sign in to comment.