Sha256: 8e7e5f91e68463918d769dc9e5225cf9c38e60ac1dbd6157d1df1bce2bb3cd66

Contents?: true

Size: 880 Bytes

Versions: 10

Compression:

Stored size: 880 Bytes

Contents

require 'junoser/xsd/base'
require 'junoser/xsd/enumeration'

module Junoser
  module Xsd
    class Restriction
      include Base

      def children
        @children||= xml.xpath('./*[not(self::xsd:annotation or ' +
                               'self::xsd:minInclusive or self::xsd:maxInclusive or ' +
                               'self::xsd:minLength or self::xsd:maxLength)]')
      end

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

      def to_s
        return format('arg') if config.empty?

        str = '(' + config.map {|c| c.to_s.strip }.compact.join(' | ') + ')'
        format(str)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

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