lib/junoser/xsd/element.rb in junoser-0.2.13 vs lib/junoser/xsd/element.rb in junoser-0.3.0

- old
+ new

@@ -1,7 +1,8 @@ require 'junoser/xsd/base' require 'junoser/xsd/complex_type' +require 'junoser/xsd/simple_type' module Junoser module Xsd class Element include Base @@ -15,21 +16,25 @@ @config ||= children.map {|child| case child.name when 'complexType' Junoser::Xsd::ComplexType.new(child, depth: @depth+1) when 'simpleType' - 'arg' + Junoser::Xsd::SimpleType.new(child, depth: @depth+1) else raise "ERROR: unknown element: #{child.name}" end } end def to_s str = case + when nokeyword? && content.empty? + format('arg') + when nokeyword? + content when content.empty? format(label) - when content =~ /^ *arg$/ + when content =~ /\A *arg\z/ format("#{label} arg") when label format("#{label} (", content, ')') else format('(', content, ')')