This is the product of the Austin Ruby Codefest 2002,
a weekend event which concluded on Wednesday.
Contributing were David Alan Black, Hal Fulton,
Nolan Darilek, and Jason Johnston.
This is a pure Ruby implementation of (most of)
the C scanf(3) function.
Look in the RAA or at this URL:
There are scanf methods added to String, IO, and
Kernel (corresponding to C’s sscanf(), fscanf(),
and plain vanilla scanf(), respectively).
There are over 130 testcases, for those who
want to know that.
Rationale for creating it:
- You can use regular expressions to retrieve
substrings, but they’re not converted automatically
to Fixnum or Float. This takes care of that.
- Given printf, sprintf, and String#%, scanf
makes sense for more completeness.
- Another bone tossed to C programmers. Those
brain cells you used learning format strings won’t
go to waste.