Class: Junoser::Xsd::Sequence
- Inherits:
-
Object
- Object
- Junoser::Xsd::Sequence
show all
- Includes:
- Base
- Defined in:
- lib/junoser/xsd/sequence.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
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/junoser/xsd/sequence.rb', line 10
def config
@config ||= children.map {|child|
case child.name
when 'choice'
Junoser::Xsd::Choice.new(child, depth: @depth+1, parent: self)
when 'element'
Junoser::Xsd::Element.new(child, depth: @depth+1, parent: self)
when 'any'
'any'
else
raise "ERROR: unknown element: #{child.name}"
end
}
end
|
#to_s ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/junoser/xsd/sequence.rb', line 25
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")
return if str.empty?
if parent.parent&.oneliner? && config.first.unbounded?
format('sc(', str, ')')
else
format('c(', str, ')')
end
else
str = config.map {|c| c.is_a?(String) ? format(OFFSET + c) : c.to_s }.reject(&:empty?).join(",\n")
format('s(', str, ')')
end
end
|