How ruby-numo/numo-narray works
Main Architectural Components
• Ruby API Layer – Represented by the code in the lib folder (especially lib/numo/narray.rb and related files). This is the public interface that users interact with.
• C Extension Layer – The core computation routines and performance-critical operations are implemented in native code under ext/numo/narray and its subdirectories. Also include the FFT components from the fft directory.
• Code Generation Pipeline – Under ext/numo/narray/gen, the library uses a set of ERB templates and Ruby scripts to generate the repetitive C code parts. This is an essential part of the build process.
• Build and Test Infrastructure – The Rakefile, test/ directory, and GitHub workflows (.github/workflows/build.yml) that compile the C code, run tests, and ensure continuous integration.
• Examples & Documentation – The notebooks (e.g., 100-narray-exercises.ipynb) and the README provide usage examples that guide the library’s interaction patterns.
Important Architectural Patterns and Design Principles
• Separation of Concerns – The project clearly separates the Ruby-level API from performance-oriented C implementations.
• Code Generation – Using ERB templates and a dedicated code generator indicates a meta-programming approach to reduce repetitive coding in C.
• Modular Design – With separate directories for FFT, tests, and documentation, the project is well organized to isolate functionalities.