diff options
author | Jakob Odersky <jakob@odersky.com> | 2019-10-22 00:55:50 -0400 |
---|---|---|
committer | Jakob Odersky <jakob@odersky.com> | 2019-11-08 22:34:57 -0500 |
commit | 99dfd5a3ececf39ae3fd30cbf9581c2fb5da2ba5 (patch) | |
tree | 59dd8a2f5283d436b300478b7197bb8ec9f5164e /yamlesque/src/main/scala/YamlPrinter.scala | |
parent | 70141fc60ec3341057627e9a8f5b83a22c74f0ea (diff) | |
download | yamlesque-0.2.0.tar.gz yamlesque-0.2.0.tar.bz2 yamlesque-0.2.0.zip |
Major refactor for version 0.2.00.2.0
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 - } - -} |