Sha256: 687a188abc03979811f10af1c3e1078f1e908cb0bf68ba33d652196b4a32fbdf

Contents?: true

Size: 735 Bytes

Versions: 10

Compression:

Stored size: 735 Bytes

Contents

require 'junoser/xsd/base'
require 'junoser/xsd/restriction'

module Junoser
  module Xsd
    class SimpleContent
      include Base

      def config
        @config ||= children.map {|child|
          case child.name
          when 'restriction'
            Junoser::Xsd::Restriction.new(child, depth: @depth+1)
          when 'extension'
            'arg'
          else
            raise "ERROR: unknown element: #{child.name}"
          end
        }.compact
      end

      def to_s
        return if config.empty?
        raise "ERROR: simpleContent shouldn't have multiple children" if config.size > 1

        child = config.first
        child.is_a?(String) ? format(OFFSET + child) : child.to_s
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
junoser-0.2.2 lib/junoser/xsd/simple_content.rb
junoser-0.2.1 lib/junoser/xsd/simple_content.rb
junoser-0.2.0 lib/junoser/xsd/simple_content.rb
junoser-0.1.6 lib/junoser/xsd/simple_content.rb
junoser-0.1.5 lib/junoser/xsd/simple_content.rb
junoser-0.1.4 lib/junoser/xsd/simple_content.rb
junoser-0.1.3 lib/junoser/xsd/simple_content.rb
junoser-0.1.2 lib/junoser/xsd/simple_content.rb
junoser-0.1.1 lib/junoser/xsd/simple_content.rb
junoser-0.1.0 lib/junoser/xsd/simple_content.rb