Module: Musa::Extension::InspectNice
- Defined in:
- lib/musa-dsl/core-ext/inspect-nice.rb
Overview
Note:
These refinements must be activated with using Musa::Extension::InspectNice
Refinements that provide more readable inspect/to_s output for Hash and Rational.
These refinements improve readability of log output and debugging, especially important when working with musical data that heavily uses Rationals for timing and Hashes for event parameters.
Changes
- Hash: Compact syntax with symbol keys shown as
key: value - Rational: Musical-friendly format like
3+1/4rinstead of(13/4) - Configurable: Rational display can switch between simple and detailed modes
Use Cases
- Improving log readability in musical applications
- Debugging DSL expressions with cleaner output
- Displaying musical time values (bars, durations) naturally
Methods Added
Hash
- Hash#inspect - Compact, readable inspect output with symbol-key shorthand
- Hash#to_s - Aliases to_s to inspect for consistency
Rational (singleton class)
- Rational#to_s_as_inspect - Controls whether Rational#to_s uses inspect format
Rational
- Rational#inspect - Musical-friendly inspect output for Rational numbers
- Rational#to_s - String representation controlled by Rational.to_s_as_inspect