[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Sc-devel] Scale
On second thought, here's a version that does a lot better at mimicking
normal object behavior:
ScaleTest {
classvar scaleDict;
var <>stepRatios;
*initClass {
scaleDict = IdentityDictionary[
\ionian -> [2, 2, 1, 2, 2, 2, 1],
\aeolian -> [2, 1, 2, 2, 1, 2, 2],
// etc.
];
}
*new {
|key|
var newScale;
newScale = super.new;
^key.notNil.if({ newScale.init(key) }, { newScale })
}
init {
|key|
stepRatios = scaleDict[key];
^stepRatios.isNil.if({ nil }, { this })
}
*doesNotUnderstand {
|selector, args|
^(scaleDict.includesKey(selector)).if({
this.new(selector)
}, {
super.doesNotUnderstand(selector, args)
})
}
}
--
Tim Walters | http://doubtfulpalace.com