Sha256: 5d5d359af4fe92621bfab1cc64c68948aca578d5ad3b797722736179927617f6

Contents?: true

Size: 727 Bytes

Versions: 24

Compression:

Stored size: 727 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
        }
      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

24 entries across 24 versions & 1 rubygems

Version Path
junoser-0.2.6 lib/junoser/xsd/simple_content.rb
junoser-0.2.5 lib/junoser/xsd/simple_content.rb
junoser-0.2.4 lib/junoser/xsd/simple_content.rb
junoser-0.2.3 lib/junoser/xsd/simple_content.rb