From 6343e644b441c686f33ffc4d4867887b60998978 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Wed, 27 Aug 2014 14:42:41 +0300 Subject: [PATCH] prepare for short hash, but no change yet --- lib/sof/hash.rb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/sof/hash.rb b/lib/sof/hash.rb index 04fbcb0d..101b5db3 100644 --- a/lib/sof/hash.rb +++ b/lib/sof/hash.rb @@ -10,8 +10,23 @@ module Sof end def out io , level = 0 super + short = true + children.each do |k,v| + short = false unless k.is_a?(SimpleNode) + short = false unless v.is_a?(SimpleNode) + end + if(short and children.length < 7 ) + short_out(io,level) + else + long_out(io , level) + end + end + def short_out(io,level) + long_out(io,level) + end + def long_out io , level indent = " " * level - @children.each_with_index do |child , i| + children.each_with_index do |child , i| key , val = child io.write "\n#{indent}" unless i == 0 io.write "-"