This project is part of the "Script Languages" subject and demonstrates the use of metaprogramming in Ruby.
This repository contains a Ruby library that implements various functionalities for handling tabular data. The primary file for examples and usage is app.rb.
The project requirements and their corresponding implementation points are outlined below:
- Return 2D array with table values
- Access rows via
t.row(1)and elements using array syntax - Implement
Enumerablemodule witheachfunction to iterate through cells - Handle merged fields within the library
- Enhance syntax for accessing specific values
- Retrieve an entire column:
t["First Column"] - Access column values:
t["First Column"][1]for the second element - Set cell value:
t["First Column"][1] = 2556
- Retrieve an entire column:
- Allow direct column access via corresponding methods
t.firstColumn,t.secondColumn,t.thirdColumn- Calculate subtotal/average:
t.firstColumn.sum,t.firstColumn.avg - Retrieve a row based on a cell value:
t.index.rn2310 - Support functions like
map,select,reduce
- Recognize and ignore rows containing keywords like "total" or "subtotal"
- Enable addition of two tables with identical headers (SQL UNION operation)
t1 + t2combines rows from both tables
- Allow subtraction of two tables with identical headers
t1 - t2removes rows from t2 that match t1
- Implementation of functionality for point 7.