Class: Junoser::Xsd::ComplexType
- Inherits:
-
Object
- Object
- Junoser::Xsd::ComplexType
- Includes:
- Base
- Defined in:
- lib/junoser/xsd/complex_type.rb
Constant Summary
Constants included from Base
Instance Attribute Summary
Attributes included from Base
Instance Method Summary collapse
- #config ⇒ Object
-
#initialize(xml, options = {}) ⇒ ComplexType
constructor
A new instance of ComplexType.
- #to_s ⇒ Object
Methods included from Base
#children, #inspect, #oneliner?, #root?
Constructor Details
#initialize(xml, options = {}) ⇒ ComplexType
Returns a new instance of ComplexType.
13 14 15 16 17 18 |
# File 'lib/junoser/xsd/complex_type.rb', line 13 def initialize(xml, = {}) super raise "ERROR: #{xml.name} shouldn't have name '#{xml['name']}'" if xml['name'] && !root? @argument = find_name_element end |
Instance Method Details
#config ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/junoser/xsd/complex_type.rb', line 20 def config @config ||= children.map do |child| case child.name when 'sequence' Junoser::Xsd::Sequence.new(child, depth: @depth + 1, parent: self) when 'simpleContent' Junoser::Xsd::SimpleContent.new(child, depth: @depth + 1, parent: self) when 'attribute' 'arg' else raise "ERROR: unknown element: #{child.name}" end end end |
#to_s ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/junoser/xsd/complex_type.rb', line 35 def to_s str = config.map { |c| c.is_a?(String) ? fmt(OFFSET + c) : c.to_s }.join("\n") str = case [!argument.nil?, !str.empty?] when [true, true] fmt("#{argument} (", str, ')') when [true, false] fmt(argument) when [false, true] simple_argument?(str) ? "#{str}.as(:arg)" : str else '' end oneliner? ? "#{str}.as(:oneline)" : str end |