Class: Hash

Inherits:
Object show all
Defined in:
lib/icss/serialization/zaml.rb

Instance Method Summary collapse

Instance Method Details

#to_zaml(z = ZAML.new) ⇒ Object



368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
# File 'lib/icss/serialization/zaml.rb', line 368

def to_zaml(z=ZAML.new)
  z.first_time_only(self) {
    z.nested {
      if empty? then z.emit('{}')
      else
        emitted = false
        each_pair{|k, v|
          z.no_comment(k){
            emitted = true
            z.nl
            z.prefix_structured_keys('? '){ k.to_zaml(z) }
            z.vpad(':', k)
            v.to_zaml(z)
          }
        }
        unless emitted then z.nl ; z.emit('{}') ; end
      end
    }
  }
end