Skip to content

Commit e779876

Browse files
author
Marije Baalman
committed
Tools: add IntegerSpec
1 parent f03b032 commit e779876

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
map from one integer spec to another
3+
*/
4+
IntegerClip {
5+
var <minval,<maxval, <default;
6+
7+
*new { |minval, maxval, default|
8+
^super.newCopyArgs( minval,maxval,default ).init;
9+
}
10+
11+
init {
12+
if ( default.isNil ){ default = minval };
13+
}
14+
15+
map { |inval|
16+
^inval.asInteger.clip( minval,maxval );
17+
}
18+
19+
// from string to number
20+
unmap { |inval|
21+
^inval.asInteger.clip( minval,maxval );
22+
}
23+
24+
asSpec {
25+
^this;
26+
}
27+
}
28+

0 commit comments

Comments
 (0)