Class: Junoser::Xsd::Restriction
- Inherits:
-
Object
- Object
- Junoser::Xsd::Restriction
- Includes:
- Base
- Defined in:
- lib/junoser/xsd/restriction.rb
Constant Summary
Constants included from Base
Instance Attribute Summary
Attributes included from Base
Instance Method Summary collapse
Methods included from Base
#initialize, #inspect, #oneliner?, #root?
Instance Method Details
#children ⇒ Object
10 11 12 13 14 |
# File 'lib/junoser/xsd/restriction.rb', line 10 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 |
#config ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/junoser/xsd/restriction.rb', line 16 def config @config ||= children.map {|child| case child.name when 'enumeration' Junoser::Xsd::Enumeration.new(child, depth: @depth+1, parent: self) when 'simpleType' Junoser::Xsd::SimpleType.new(child, depth: @depth+1, parent: self) when 'attribute' else raise "ERROR: unknown element: #{child.name}" end }.compact end |
#to_s ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/junoser/xsd/restriction.rb', line 30 def to_s return format('arg') if config.empty? str = enumeration? ? 'enum' : '' str += '(' + config.map {|c| c.to_s.strip }.join(' | ') + ')' format(str) end |