Class

net.fosdal.oslo.ostring

StringOps

Related Doc: package ostring

Permalink

implicit final class StringOps extends AnyVal

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. StringOps
  2. AnyVal
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new StringOps(s: String)

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    Any
  4. def asBytes: Long

    Permalink

    Converts the scala.Predef.String representation of memory (e.g.

    Converts the scala.Predef.String representation of memory (e.g. 10mb, 1.1kb, etc.) to a scala.Long representation of the number of bytes. It is forgiving of leading and trailing whitespace as well as whitespace between the numerical portion and the unit of memory.

    If the scala.Predef.String does not match any known representation of memory, the fallback is to attempt to convert the entire scala.Predef.String to a scala.Long

    For consistency, rounding to scala.Long is used in both of the above cases.

    Examples

    scala> val foo = "1.5kb".asBytes
    foo: Long = 1536
    
    // fall back using toLong
    scala> val foo = "1100b".asBytes
    foo: Long = 1100
    scala> val foo = "1100".asBytes
    foo: Long = 1100
    
    // rounding, would otherwise be 9341.952b
    scala> val foo = "9.123kb".asBytes
    foo: Long = 9342
    
    // fallback rounding, for consistency
    scala> val foo = "9.1b".asBytes
    foo: Long = 9
    scala> val foo = "9.1".asBytes
    foo: Long = 9
    Annotations
    @throws( classOf[NumberFormatException] )
    Version

    0.3.0

    Exceptions thrown

    java.lang.NumberFormatException - If the string does not contain a memory representation that is parsable to a scala.Long

  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def getClass(): Class[_ <: AnyVal]

    Permalink
    Definition Classes
    AnyVal → Any
  7. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  8. val s: String

    Permalink
  9. def toAlpha: String

    Permalink

    removes all non-alpha characters from the scala.Predef.String (non-[a-zA-Z])

    removes all non-alpha characters from the scala.Predef.String (non-[a-zA-Z])

    Example

    scala> val foo = "a1b2c3!@#".toAlpha
    foo: String = abc
    Version

    0.3.0

  10. def toAlphanumeric: String

    Permalink

    removes all non-alphanumeric characters from the scala.Predef.String (non-[0-9a-zA-Z])

    removes all non-alphanumeric characters from the scala.Predef.String (non-[0-9a-zA-Z])

    Example

    scala> val foo = "a1b2c3!@#".toAlphanumeric
    foo: String = a1b2c3
    Version

    0.3.0

  11. def toNumeric: String

    Permalink

    removes all non-numeric characters from the scala.Predef.String (non-[0-9])

    removes all non-numeric characters from the scala.Predef.String (non-[0-9])

    Example

    scala> val foo = "a1b2c3!@#".toNumeric
    foo: String = 123
    Version

    0.3.0

  12. def toString(): String

    Permalink
    Definition Classes
    Any

Inherited from AnyVal

Inherited from Any

Ungrouped