37 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto 34b94129d2 mruby-hash-ext: remove non-compatible Hash#deconstruct_keys
CRuby's Hash#deconstruct_keys simply returns self regardless of
arguments. The mruby-hash-ext version filtered keys, which was
unnecessary since the compiler accesses individual keys via []
after calling deconstruct_keys. The Ruby implementation in
mrblib/hash.rb (returning self) is sufficient and CRuby-compatible.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-16 16:57:21 +09:00
Yukihiro "Matz" Matsumoto 8c4db2f417 mruby-hash-ext: add Hash#slice!
This commit introduces `Hash#slice!`, which removes key-value pairs from a
hash, keeping only the ones specified in the arguments. The removed pairs
are returned as a new hash.

Co-authored-by: Gemini <gemini@google.com>
2025-07-01 23:23:07 +09:00
Yukihiro "Matz" Matsumoto 33d6ec08f3 mruby-hash-ext: enhance __merge for multiple arguments
Replace single-argument __merge with multi-argument C implementation.
Eliminates Ruby loop overhead for merging multiple hashes.
Optimizes merge! method while maintaining block functionality.

Co-authored-by: Atlassian Rovo Dev
2025-07-01 22:34:31 +09:00
Yukihiro "Matz" Matsumoto 6e79fed77b mruby-hash-ext: add Hash#deconstruct_keys for pattern matching
Implement new method for Ruby 2.7+ pattern matching compatibility.
Handles nil (return self) and array (extract keys) arguments.
Enables modern case/in pattern matching syntax in mruby.

Co-authored-by: Atlassian Rovo Dev
2025-07-01 16:02:42 +09:00
Yukihiro "Matz" Matsumoto 9cda737a56 mruby-hash-ext/test: test Hash#compact! returns nil if unmodified 2023-02-02 22:42:36 +09:00
John Bampton ea8964ef35 ruby: standardize whitespace 2022-10-31 16:25:56 +10:00
Yukihiro "Matz" Matsumoto 909e1044ed mruby-hash-ext/hash.rb (merge!): takes multiple arguments. 2022-06-18 16:12:14 +09:00
Seeker 14a92f9705 Add Hash#except [Ruby 3.0] 2020-12-27 16:33:12 -08:00
KOBAYASHI Shuji ea2424d36d Drop test dependency from mruby-hash-ext to mruby-enumerator 2019-11-06 18:57:35 +09:00
Yukihiro "Matz" Matsumoto 5bbcea9b3b Removed try_convert method from Array and Hash. 2018-11-19 12:08:28 +09:00
Yukihiro "Matz" Matsumoto 421819dc2c Add Hash#slice [Ruby 2.5] 2017-12-25 23:43:37 +09:00
Yukihiro "Matz" Matsumoto df68a3345d assert_equal() takes result as the first argument 2017-12-25 15:39:45 +09:00
vvakame 4d46f366ac add method(compact, compact!) and test of Hash to mruby-hash-ext 2017-08-09 19:18:02 +09:00
Yukihiro "Matz" Matsumoto 515a093213 Add Hash#transform_keys! and Hash#transform_values. 2017-07-15 08:51:35 +09:00
Yukihiro "Matz" Matsumoto 460d628490 Remove duplication in mruby-hash-ext test. 2017-07-14 16:10:26 +09:00
Yukihiro "Matz" Matsumoto de3edcc170 Add Hash#transform_{keys,values} to mruby-hash-ext. 2017-07-14 15:13:41 +09:00
Kouhei Sutou e72e50b5d5 Hash sub class creates new sub class objects instead of Hash 2017-03-21 23:25:36 +09:00
Yukihiro "Matz" Matsumoto 817b884343 add #dig tests 2016-03-23 12:34:32 +09:00
takahashim 621487a0cd add {Array|Hash|String}.try_convert 2015-11-24 08:39:39 +09:00
Yukihiro "Matz" Matsumoto fa86026a99 move Hash comparison methods to mruby-hash-ext gem 2015-11-15 05:15:20 +09:00
Jun Hiroe 570c261555 Refator Hash.fetch test 2015-09-26 09:58:36 +09:00
Asmod4n 4bd98671bc Problem: Hash#fetch doesn't raise KeyError when a key cannot be found
Solution: change the Exception class raised to KeyError when a key
cannot be found.
2015-09-17 13:28:09 +02:00
takahashim b88ca625ab fix block variable in Hash#fetch 2015-09-16 02:57:41 +09:00
INOUE Yasuyuki 5603b8d79f implement Hash.[] 2014-09-06 22:50:06 +09:00
Yukihiro "Matz" Matsumoto 172060877a add Hash#to_h; ref #2348 2014-06-04 18:57:31 +09:00
yui-knk 658a00ba49 Change to raise TypeError (Hash#merge, #merge!) 2014-05-10 10:18:15 +09:00
Jun Hiroe dc4c042df5 Add Hash#key 2014-05-09 00:46:33 +09:00
Jun Hiroe dcad562f73 Add Hash#keep_if 2014-05-05 20:26:28 +09:00
Jun Hiroe 015f60fcad Add Hash#invert 2014-05-05 11:15:48 +09:00
Jun Hiroe 28a858c17e Add Hash#flatten 2014-05-04 21:14:13 +09:00
Jun Hiroe 3e7db4ad27 Add Hash#delete_if 2014-05-04 00:46:36 +09:00
Nobuyoshi Nakada ab67c57f65 remove trailing spaces 2014-04-30 09:50:14 +09:00
Yukihiro "Matz" Matsumoto 7e175d8130 add Hash#fetch; close #2134 2014-04-27 03:03:27 +09:00
take_cheeze 658b4f4ea7 add test(requires MRB_GC_FIXED_ARENA enabled) 2014-02-22 00:28:38 +09:00
Daniel Bovensiepen b4e07a8051 Improve test of mruby-hash-ext GEM 2013-08-04 22:41:15 +08:00
Masaki Muranaka a46eacb213 Move Hash#values_at to mruby-hash-ext gem. 2013-05-08 13:22:35 +09:00
Kouki Ooyatsu dfe2359b0c add mruby-hash-ext mrbgem, and method: Hash#merge! 2013-03-22 17:10:42 +09:00