Method: Zafu::Parser#inspect

Defined in:
lib/zafu/parser.rb

#inspectObject



630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
# File 'lib/zafu/parser.rb', line 630

def inspect
  attributes = []
  params = []
  (@params || {}).each do |k,v|
    unless v.nil?
      params << "#{k.inspect.gsub('"', "'")}=>'#{v}'"
    end
  end
  attributes << " {= #{params.sort.join(', ')}}" unless params == []

  context = []
  (@context || {}).each do |k,v|
    unless v.nil?
      context << "#{k.inspect.gsub('"', "'")}=>'#{v}'"
    end
  end
  attributes << " {> #{context.sort.join(', ')}}" unless context == []

  res = []
  @blocks.each do |b|
    if b.kind_of?(String)
      res << b
    else
      res << b.inspect
    end
  end
  result = "[#{@method}#{attributes.join('')}"
  if res != []
    result += "]#{res}[/#{@method}]"
  else
    result += "/]"
  end
  result + @text
end