class QuantityParser extends Serializable
A class that can parse an expression into a unit-typed Quantity
import coulomb.parser._ // declare a parser with a particular set of legal units val qp = QuantityParser[Meter :: Second :: Kilo :: HNil] val duration = qp[Int, Minute]("60 second") // a duration of one minute val speed = qp[Double, Mile %/ Hour]("10.0 kilometer / second") // prefix units are parsed
- Alphabetic
- By Inheritance
- QuantityParser
- Serializable
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def apply[N, U](quantityExpr: String)(implicit ntt: scala.reflect.api.JavaUniverse.WeakTypeTag[N], uts: UnitTypeString[U]): Try[Quantity[N, U]]
Parse an expression into a unit typed Quantity
Parse an expression into a unit typed Quantity
- N
numeric type of the quantity
- U
the unit type - must be compatible (convertable) with the unit type in the expression
- quantityExpr
the unit quantity expression. A number followed by a unit expression, where individual units are given by their full names (e.g. "meter", "second", etc), and operators "/", "*", "^". Prefix units may be prepended, e.g. "kilometer". Sub-expressions may be contained in parentheses, e.g. "9.8 meter / (second ^ 2)"
- returns
a Try value wrapping a Quantity with type parameters N, U. This Try will be Failure(...) in the event of eiher a parsing error or failure to convert the unit expression into Quantity[N,U]
- def applyUnitExpr[V, U2](v: V, u1: String)(implicit vtt: scala.reflect.api.JavaUniverse.WeakTypeTag[V], ut2: UnitTypeString[U2]): Try[Quantity[V, U2]]
Parse a unit expression and apply it to a value
Parse a unit expression and apply it to a value
- V
the value type
- U2
the output unit type
- v
the raw value
- u1
the unit expression string, encodes a unit type
U1
e.g. "meter / (second ^ 2)"- returns
a Try value wrapping
Quantity[V, U2]
. Effectively, generatesv.withUnit[U1].toUnit[U2]
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def coefficient[U2](u1: String)(implicit ut2: UnitTypeString[U2]): Try[Rational]
Parse a unit expression and obtain the conversion coefficient to another unit
Parse a unit expression and obtain the conversion coefficient to another unit
- U2
the unit being converted to
- u1
the unit expression string, encodes a unit type
U1
- returns
a Try value wrapping the coefficient from U1 -> U2
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()