From 3c00a7e2048ed274c1d3dfc0af8d0efffad891fc Mon Sep 17 00:00:00 2001 From: Gears JS Date: Sat, 20 May 2023 14:12:15 +0100 Subject: [PATCH] tweak: Groups wil not return an array containing a singla element --- .ruby-version | 1 - lib/parsby/combinators.rb | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) delete mode 100644 .ruby-version diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index 005119b..0000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.4.1 diff --git a/lib/parsby/combinators.rb b/lib/parsby/combinators.rb index 28d0e47..d99a783 100644 --- a/lib/parsby/combinators.rb +++ b/lib/parsby/combinators.rb @@ -320,11 +320,11 @@ def splicer # Groups results into an array. define_combinator :group do |*ps| ps = ps.flatten - ~splicer.start do |m| + (~splicer.start { |m| ps.reduce(empty) do |a, p| a << m.end(p) end - end + }).fmap { |result| result.size == 1 ? result.first : result } end # Wraps result in a list. This is to be able to do