Skip to content

Commit

Permalink
Move base units from kilogram to gram and use prefix for kilogram.
Browse files Browse the repository at this point in the history
This commit also remove some duplicated code.

Fixes zweidenker#16 and Fixes zweidenker#15
  • Loading branch information
jecisc committed Oct 27, 2018
1 parent 1b9b4b9 commit be5e29c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 60 deletions.
3 changes: 3 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
'srcDirectory' : 'src'
}
62 changes: 7 additions & 55 deletions src/Units-Core/BaseUnit.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ BaseUnit class >> ampere [
^self withSingularName: 'ampere'
]

{ #category : #'base units' }
BaseUnit class >> amperes [

^self ampere
]

{ #category : #example }
BaseUnit class >> basePair [

Expand Down Expand Up @@ -79,16 +73,22 @@ BaseUnit class >> donuts [
^ self donut
]

{ #category : #'base units' }
BaseUnit class >> gram [
^ self withSingularName: 'gram'
]

{ #category : #initialization }
BaseUnit class >> initializeClass [
<script>
"BaseUnit initializeClass."
"Do not rename this to #initialize."
PrintAbbreviated := false. "may as well do it here ..."
SIUnitsByName := Dictionary new.
SIUnitsByAbbreviation := Dictionary new.
SIUnitsByPluralName := Dictionary new.
self
addUnit: 'kilogram' plural: 'kilograms' abbreviation: 'kg';
addUnit: 'gram' plural: 'grams' abbreviation: 'g';
addUnit: 'metre' plural: 'metres' abbreviation: 'm';
addUnit: 'second' plural: 'seconds' abbreviation: 's';
addUnit: 'candela' plural: 'candela' abbreviation: 'cd';
Expand All @@ -107,78 +107,30 @@ BaseUnit class >> kelvin [
^self withSingularName: 'kelvin'
]

{ #category : #'base units' }
BaseUnit class >> kilogram [

^self withSingularName: 'kilogram'
]

{ #category : #'base units' }
BaseUnit class >> kilograms [

^ self kilogram
]

{ #category : #'base units' }
BaseUnit class >> meter [

^self metre
]

{ #category : #'base units' }
BaseUnit class >> meters [

^self metre
]

{ #category : #'base units' }
BaseUnit class >> metre [

^self withSingularName: 'metre'
]

{ #category : #'base units' }
BaseUnit class >> metres [

^ self metre
]

{ #category : #'base units' }
BaseUnit class >> mole [

^self withSingularName: 'mole'
]

{ #category : #'base units' }
BaseUnit class >> moles [

^self mole
]

{ #category : #'base units' }
BaseUnit class >> second [

^self withSingularName: 'second'
]

{ #category : #'base units' }
BaseUnit class >> seconds [

^ self second
]

{ #category : #'base units' }
BaseUnit class >> volt [

^self withSingularName: 'volt'
]

{ #category : #'base units' }
BaseUnit class >> volts [

^self volt
]

{ #category : #accessing }
BaseUnit class >> withAbbreviation: abbreviation ifAbsent: exceptionBlock [
^SIUnitsByAbbreviation
Expand Down
8 changes: 3 additions & 5 deletions src/Units-Core/Unit.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,7 @@ Unit class >> gigavolt [

{ #category : #'mass units' }
Unit class >> gram [

^NamedUnit named: 'gram'
^ BaseUnit gram
]

{ #category : #'mass units' }
Expand Down Expand Up @@ -410,8 +409,7 @@ Unit class >> kg [

{ #category : #'mass units' }
Unit class >> kilogram [

^ BaseUnit kilogram
^ self gram prefixedBy: 'kilo'
]

{ #category : #'mass units' }
Expand Down Expand Up @@ -890,7 +888,7 @@ Unit class >> volt [
{ #category : #'power units' }
Unit class >> volts [

^ BaseUnit volts
^ self volt
]

{ #category : #'power units' }
Expand Down

0 comments on commit be5e29c

Please sign in to comment.