All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.dahgan.parser.Chomp.kt Maven / Gradle / Ivy

The newest version!
package io.dahgan.parser

/**
 * Chomp method.
 */
enum class Chomp(val text: String) {
    /**
     * Remove all trailing line breaks.
     */
    Strip("strip"),

    /**
     * Keep first trailing line break.
     */
    Clip("clip"),

    /**
     * Keep all trailing line breaks.
     */
    Keep("keep");

    override fun toString(): String = text

    companion object {
        fun from(word: String): Chomp = when (word) {
            "strip" -> Strip
            "clip" -> Clip
            "keep" -> Keep
            else -> throw IllegalArgumentException("unknown chomp: $word")
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy