From 8f42a3daed728e12e6af61d858628a43a2518134 Mon Sep 17 00:00:00 2001 From: Fraser Hanson Date: Wed, 5 Feb 2025 10:19:09 -0800 Subject: [PATCH] chore: README tidying --- README.md | 10 ++++++---- lib/janeway/enumerator.rb | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 00e75f1..5c77fb6 100644 --- a/README.md +++ b/README.md @@ -192,7 +192,7 @@ For example, iterating over an array may yield index values 1, 2 and 3. Deleting the value at index 1 would change the index for the remaining values. Next iteration might yield index 2, but since 1 was deleted it is now really at index 1. -To avoid having to deal with such problems, use the built in `#delete` method below. +To avoid having to deal with such problems, use the `#delete` method instead. Lastly, the `#each` iterator's fourth yield parameter is the [normalized path](https://www.rfc-editor.org/rfc/rfc9535.html#name-normalized-paths) to the matched value. @@ -205,8 +205,10 @@ This is a jsonpath query string that uniquely points to the matched value. paths << path end paths - # [ # "$['birds']", "$['dogs']", "$['birds'][0]", "$['birds'][1]", "$['birds'][2]", - # "$['dogs'][0]", "$['dogs'][1]", "$['dogs'][2]"] + # [ + # "$['birds']", "$['dogs']", "$['birds'][0]", "$['birds'][1]", + # "$['birds'][2]", "$['dogs'][0]", "$['dogs'][1]", "$['dogs'][2]" + # ] ``` ##### #delete @@ -224,7 +226,7 @@ The `#delete` method deletes matched values from the input. ##### #delete_if -The `#delete_if` method yields matched values to a block, and deletes them if the block returns a truthy value. +The `#delete_if` method yields matched values to a block, and deletes them if the block returns a truthy result. This allows values to be deleted based on conditions that can't be tested by a JSONPath query: ```ruby # delete any book from the store json data that is not in the database diff --git a/lib/janeway/enumerator.rb b/lib/janeway/enumerator.rb index 7f9473c..bd3642d 100644 --- a/lib/janeway/enumerator.rb +++ b/lib/janeway/enumerator.rb @@ -54,7 +54,7 @@ def delete_if(&block) end # Assign the given value at every query match. - # @param value [Object] + # @param replacement [Object] # @return [void] def replace(replacement = :no_replacement_value_was_given, &block) if replacement != :no_replacement_value_was_given && block_given?