--- a/Fraction.st Fri Aug 28 12:38:51 2009 +0100
+++ b/Fraction.st Sat Oct 24 16:48:19 2009 +0100
@@ -131,6 +131,41 @@
Fraction numerator:1 denominator:0
Fraction numerator:2 denominator:0
"
+!
+
+readFrom:aStringOrStream onError:exceptionBlock
+ |s numerator denominator|
+
+ "/ sigh - care for subclasses...
+ self == Fraction ifFalse:[
+ ^ super readFrom:aStringOrStream onError:exceptionBlock
+ ].
+
+ s := aStringOrStream readStream.
+ s skipSeparators.
+ s peek == $( ifTrue:[
+ s next.
+
+ ].
+
+ numerator := super readFrom:s onError:[^ exceptionBlock value].
+ numerator isInteger ifTrue:[
+ s skipSeparators.
+ (s peek == $/) ifTrue:[
+ s next.
+ denominator := Integer readFrom:s onError:[^ exceptionBlock value].
+ ^ self numerator:numerator denominator:denominator
+ ].
+ ^ numerator
+ ].
+ ^ numerator asFraction
+
+ "
+ Fraction readFrom:'1'
+ Fraction readFrom:'2'
+ Fraction readFrom:'1.5'
+ Fraction readFrom:'1/5'
+ "
! !
!Fraction class methodsFor:'class initialization'!
@@ -1123,7 +1158,8 @@
!Fraction class methodsFor:'documentation'!
version
- ^ '$Id: Fraction.st 10448 2009-06-14 16:10:51Z vranyj1 $'
+ ^ '$Id: Fraction.st 10473 2009-10-24 15:48:19Z vranyj1 $'
! !
Fraction initialize!
+