/** This is a class that parses information about a tire maybe using American tire specifications. */ class Tire { var width var aspect var wheelDiameter var construction var sidewallHeight var tireDiameter /** Construct a new tire specification from a string like "265/50 R 20" */ new[str] := { if [usage, width, aspect, construction, wheelDiameter] = str =~ %r/^([A-Z]+)\s*(\d+)\s*\/\s*(\d+)\s*([A-Z]+?)\s*(\d+)/i { println["matched $str"] width = eval[width] mm println["width is parsed as $width"] aspect = eval[aspect] wheelDiameter = eval[wheelDiameter] in println["wheel diameter is $wheelDiameter"] println["Construction is $construction"] sidewallHeight = aspect/100 width tireDiameter = wheelDiameter + 2 sidewallHeight } else { println["unmatched line $str"] } } }