Class: Junoser::Xsd::Choice
- Inherits:
-
Object
- Object
- Junoser::Xsd::Choice
show all
- Includes:
- Base
- Defined in:
- lib/junoser/xsd/choice.rb
Constant Summary
Constants included
from Base
Base::OFFSET
Instance Attribute Summary
Attributes included from Base
#parent, #xml
Instance Method Summary
collapse
Methods included from Base
#children, #initialize, #inspect, #oneliner?, #root?
Instance Method Details
#config ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/junoser/xsd/choice.rb', line 11
def config
@config ||= children.map do |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
end
|
#to_s ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'lib/junoser/xsd/choice.rb', line 24
def to_s
if config.empty?
''
elsif has_single_child_of?(Junoser::Xsd::Choice)
fmt('c(', config.first.config.map(&:to_s).join(",\n"), ')')
else
fmt('c(', config.map(&:to_s).join(",\n"), ')')
end
end
|
#unbounded? ⇒ Boolean
34
35
36
|
# File 'lib/junoser/xsd/choice.rb', line 34
def unbounded?
xml['maxOccurs'] == 'unbounded'
end
|