Packages

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
Linear Supertypes
Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. QuantityParser
  2. Serializable
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. 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]

  5. 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, generates v.withUnit[U1].toUnit[U2]

  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  8. 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

  9. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  10. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  12. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  13. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  14. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  15. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  17. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  18. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  19. def toString(): String
    Definition Classes
    AnyRef → Any
  20. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  21. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  22. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped