-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into release-1.3
- Loading branch information
Showing
21 changed files
with
548 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 4 additions & 6 deletions
10
.../squants/formatter/DefaultFormatter.scala → ...rimental/formatter/DefaultFormatter.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
shared/src/main/scala/squants/experimental/formatter/Formatter.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package squants.experimental.formatter | ||
|
||
import squants.Quantity | ||
|
||
trait Formatter[A <: Quantity[A]] { | ||
def inBestUnit(quantity: Quantity[A]): A | ||
} |
33 changes: 33 additions & 0 deletions
33
shared/src/main/scala/squants/experimental/formatter/Formatters.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package squants.experimental.formatter | ||
|
||
import squants.Quantity | ||
import squants.information.Information | ||
import squants.mass._ | ||
import squants.space.Length | ||
import squants.experimental.unitgroups.UnitGroup | ||
import squants.experimental.unitgroups.information.{IECInformation, MetricInformation} | ||
import squants.experimental.unitgroups.misc.{AstronomicalLengthUnitGroup, TroyMasses} | ||
|
||
object Formatters { | ||
val AstroUnitFormatter: DefaultFormatter[Length] = new DefaultFormatter(AstronomicalLengthUnitGroup) | ||
|
||
val TroyFormatter: DefaultFormatter[Mass] = new DefaultFormatter(TroyMasses) | ||
|
||
val InformationMetricFormatter: DefaultFormatter[Information] = new DefaultFormatter(MetricInformation) | ||
|
||
val InformationIECFormatter: DefaultFormatter[Information] = new DefaultFormatter(IECInformation) | ||
} | ||
|
||
object implicits { | ||
implicit def implicitFormatter[A <: Quantity[A]](implicit implicitUnitGroup: UnitGroup[A]): Formatter[A] = { | ||
new DefaultFormatter[A](implicitUnitGroup) | ||
} | ||
} | ||
|
||
object syntax { | ||
implicit class FormattedQuantity[A <: Quantity[A]](quantity: Quantity[A]) { | ||
def inBestUnit(implicit formatter: Formatter[A]): Quantity[A] = { | ||
formatter.inBestUnit(quantity) | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...uants/unitgroups/ImplicitDimensions.scala → ...ental/unitgroups/ImplicitDimensions.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ants/unitgroups/information/package.scala → ...ntal/unitgroups/information/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ala/squants/unitgroups/misc/package.scala → ...xperimental/unitgroups/misc/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...ants/unitgroups/si/expanded/package.scala → ...ntal/unitgroups/si/expanded/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...quants/unitgroups/si/strict/package.scala → ...mental/unitgroups/si/strict/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ants/unitgroups/uscustomary/package.scala → ...ntal/unitgroups/uscustomary/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.