Sha256: 01efc1e33774ccc35bbdc162378abad6d601fecff4497da53fd23c65c24be176

Contents?: true

Size: 1016 Bytes

Versions: 24

Compression:

Stored size: 1016 Bytes

Contents

require 'junoser/xsd/base'
require 'junoser/xsd/choice'
require 'junoser/xsd/element'

module Junoser
  module Xsd
    class Sequence
      include Base

      def config
        @config ||= children.map {|child|
          case child.name
          when 'choice'
            Junoser::Xsd::Choice.new(child, depth: @depth+1)
          when 'element'
            Junoser::Xsd::Element.new(child, depth: @depth+1)
          when 'any'
            'any'
          else
            raise "ERROR: unknown element: #{child.name}"
          end
        }
      end

      def to_s
        case
        when config.empty?
        when has_single_child_of?(Junoser::Xsd::Choice)
          child = config.first
          str = child.config.map(&:to_s).reject(&:empty?).join(",\n")
          format('c(', str, ')') unless str.empty?
        else
          str = config.map {|c| c.is_a?(String) ? format(OFFSET + c) : c.to_s }.reject(&:empty?).join(",\n")
          format('s(', str, ')')
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
junoser-0.3.12 lib/junoser/xsd/sequence.rb
junoser-0.3.11 lib/junoser/xsd/sequence.rb
junoser-0.3.10 lib/junoser/xsd/sequence.rb
junoser-0.3.9 lib/junoser/xsd/sequence.rb
junoser-0.3.8 lib/junoser/xsd/sequence.rb
junoser-0.3.7 lib/junoser/xsd/sequence.rb
junoser-0.3.6 lib/junoser/xsd/sequence.rb
junoser-0.3.5 lib/junoser/xsd/sequence.rb
junoser-0.3.4 lib/junoser/xsd/sequence.rb
junoser-0.3.3 lib/junoser/xsd/sequence.rb
junoser-0.3.2 lib/junoser/xsd/sequence.rb
junoser-0.3.1 lib/junoser/xsd/sequence.rb
junoser-0.3.0 lib/junoser/xsd/sequence.rb
junoser-0.2.13 lib/junoser/xsd/sequence.rb
junoser-0.2.12 lib/junoser/xsd/sequence.rb
junoser-0.2.11 lib/junoser/xsd/sequence.rb
junoser-0.2.10 lib/junoser/xsd/sequence.rb
junoser-0.2.9 lib/junoser/xsd/sequence.rb
junoser-0.2.8 lib/junoser/xsd/sequence.rb
junoser-0.2.7 lib/junoser/xsd/sequence.rb