RubyGems
The gem is available here VisualArrayGem
VisualArray
Description
VisualArray is a Ruby gem that displays arrays in a structured, visually appealing tabular format. It supports 1D, 2D, and multi-dimensional arrays with options for customizing text color.
Installation
Add this line to your application's Gemfile:
bundle add visual_array
Or install it manually:
gem install visual_array
Usage
Basic Example
require 'visual_array'
VisualArray.display([1, 2, 3, 4])
Output:
+---+---+---+---+
| 1 | 2 | 3 | 4 |
+---+---+---+---+
2D Array Example
VisualArray.display([
[1, 2],
[3, 4]
])
Output:
+-----+-----+
| 1 | 2 |
| 3 | 4 |
+-----+-----+
Multi-Dimensional Array Example
VisualArray.display([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
Output:
Dimension 1, Index 0:
+-----+-----+
| 1 | 2 |
| 3 | 4 |
+-----+-----+
Dimension 1, Index 1:
+-----+-----+
| 5 | 6 |
| 7 | 8 |
+-----+-----+
Customizing Color
You can pass optional color
parameter:
VisualArray.display(
[[[1, 2], [3, 4]], [[5, 6], [7, 8]]],
color: 'blue'
)
Visual Representation
Development
After checking out the repo, run:
bin/setup
to install dependencies. Use bin/console
for an interactive session.
To install this gem locally:
bundle exec rake install
To release a new version:
- Update the version in
version.rb
.
- Run:
bundle exec rake release
This will create a git tag, push commits, and publish the gem to RubyGems.
Contributing
Bug reports and pull requests are welcome at GitHub.
License
This project is available under the MIT License.