diff options
Diffstat (limited to 'yamlesque/src/main/scala/YamlPrinter.scala')
-rw-r--r-- | yamlesque/src/main/scala/YamlPrinter.scala | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/yamlesque/src/main/scala/YamlPrinter.scala b/yamlesque/src/main/scala/YamlPrinter.scala deleted file mode 100644 index 083a8a8..0000000 --- a/yamlesque/src/main/scala/YamlPrinter.scala +++ /dev/null @@ -1,48 +0,0 @@ -package yamlesque - -import annotation.tailrec - -class YamlPrinter(compact: Boolean = true) extends (YamlValue => String) { - - def apply(value: YamlValue): String = { - val str = new StringBuilder() - def p(value: YamlValue, indentation: Int): Unit = value match { - case YamlScalar(value) => - str ++= " " * indentation - str ++= value - str += '\n' - case YamlSequence(items) => - for (item <- items) { - str ++= " " * indentation - item match { - case YamlScalar(v) if compact => - str ++= "- " - str ++= v - str += '\n' - case _ => - str ++= "-\n" - p(item, indentation + 1) - } - } - case YamlMapping(fields) => - for ((key, value) <- fields) { - str ++= " " * indentation - str ++= key - value match { - case YamlScalar(v) if compact => - str ++= ": " - str ++= v - str += '\n' - case _ => - str ++= ":\n" - p(value, indentation + 1) - } - } - case YamlEmpty => - str += '\n' - } - p(value, 0) - str.toString - } - -} |