Sha256: 591124bd55f934eb7965c4360a295255648a150f8b9cd98e025ed2327b6eff2c

Contents?: true

Size: 898 Bytes

Versions: 17

Compression:

Stored size: 898 Bytes

Contents

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

module Junoser
  module Xsd
    class Choice
      include Base

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

      def to_s
        case
        when config.empty?
          ''
        when has_single_child_of?(Junoser::Xsd::Choice)
          format('c(', config.first.config.map(&:to_s).join(",\n"), ')')
        else
          format('c(', config.map(&:to_s).join(",\n"), ')')
        end
      end

      def unbounded?
        xml['maxOccurs'] == 'unbounded'
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
junoser-0.6.0 lib/junoser/xsd/choice.rb
junoser-0.5.6 lib/junoser/xsd/choice.rb
junoser-0.5.5 lib/junoser/xsd/choice.rb
junoser-0.5.4 lib/junoser/xsd/choice.rb
junoser-0.5.3 lib/junoser/xsd/choice.rb
junoser-0.5.2 lib/junoser/xsd/choice.rb
junoser-0.5.1 lib/junoser/xsd/choice.rb
junoser-0.5.0 lib/junoser/xsd/choice.rb
junoser-0.4.7 lib/junoser/xsd/choice.rb
junoser-0.4.6 lib/junoser/xsd/choice.rb
junoser-0.4.5 lib/junoser/xsd/choice.rb
junoser-0.4.4 lib/junoser/xsd/choice.rb
junoser-0.4.3 lib/junoser/xsd/choice.rb
junoser-0.4.2 lib/junoser/xsd/choice.rb
junoser-0.4.1 lib/junoser/xsd/choice.rb
junoser-0.4.0 lib/junoser/xsd/choice.rb
junoser-0.3.13 lib/junoser/xsd/choice.rb