10 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto 531d5a76e5 mruby-enum-chain: add parentheses to to_enum call
added parentheses to to_enum call where the return value is used,
explicitly specifying :each for readability.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:06 +09:00
Yukihiro "Matz" Matsumoto 6f35e05350 mruby-enum-chain: add comprehensive call-seq documentation for enumerator chaining
Added complete call-seq documentation for all enumerator chain methods in
mrblib/chain.rb (8 methods):

## Enumerable Extension Methods:

- chain: creates Enumerator::Chain from multiple enumerables for sequential
  iteration, enabling fluent chaining of enumerable objects

## Enumerator Extension Methods:

- +: operator overload for creating chains from two enumerators, provides
  convenient syntax for combining enumerators

## Enumerator::Chain Class Methods:

- new: constructor for creating chain from multiple enumerable arguments,
  stores enumerables and initializes position tracking

## Enumerator::Chain Instance Methods:

- each: core iteration method that sequentially processes all chained
  enumerables, supports both block and enumerator return modes

- size: calculates total size across all chained enumerables, returns nil
  if any enumerable doesn't support size method

- rewind: resets iteration state by rewinding all previously iterated
  enumerables in reverse order, maintains proper state management

- +: creates new chain by appending additional enumerable to existing chain,
  enables further composition of enumerator chains

- inspect: provides debugging representation showing internal enumerable
  structure for development and troubleshooting

Co-authored-by: Atlassian Rovo Dev
2025-08-14 10:52:45 +09:00
Yukihiro "Matz" Matsumoto 74f46a05fd mruby-enum-chain: add README.md
The document is written by Google Jules.
2025-06-13 04:42:17 +09:00
KOBAYASHI Shuji 66211394e1 Enumerator::Chain#rewind shouldn't rewind elements aren't iterated
### Example:

  ```ruby
  # example.rb
  e = [1]
  def e.rewind; p :r end
  c = e.chain(e)
  c.each{break c}.rewind
  ```

#### Before this patch:

  ```terminal
  $ bin/mruby example.rb
  :r
  :r
  ```

#### After this patch (same as Ruby):

  ```terminal
  $ bin/mruby example.rb
  :r
  ```
2019-09-02 08:58:33 +09:00
Yukihiro "Matz" Matsumoto 3ac98009d3 Merge pull request #4602 from shuujii/remove-EnumeratorChain-initialize_copy
Remove `Enumerator::Chain#initialize_copy`
2019-07-28 23:44:11 +09:00
KOBAYASHI Shuji 7f80a5f73c Define #+ to Enumerator and Enumerator#Chain instead of Enumerable 2019-07-28 22:52:24 +09:00
KOBAYASHI Shuji 27e3d92a30 Remove Enumerator::Chain#initialize_copy
I think `Enumerator::Chain#initialize_copy` is unnecessary because CRuby
doesn't clone elements.
2019-07-28 22:12:02 +09:00
KOBAYASHI Shuji fe9a58c193 Drop dependency from mruby-enum-chain to mruby-enum-ext 2019-07-27 20:45:14 +09:00
dearblue f392337e10 Add test for Enumerator::Chain 2019-01-03 18:16:26 +09:00
dearblue a98359faa7 Add enumerator chain feature (CRuby-2.6 compatible)
- Enumerator::Chain
  - Enumerable#chain
  - Enumerable#+
2019-01-03 18:16:26 +09:00