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.
11 12 13 14 15 |
# File 'lib/junoser/xsd/complex_type.rb', line 11 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
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/junoser/xsd/complex_type.rb', line 17 def config @config ||= children.map {|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 |
#to_s ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/junoser/xsd/complex_type.rb', line 32 def to_s str = config.map {|c| c.is_a?(String) ? format(OFFSET + c) : c.to_s }.join("\n") str = case [!argument.nil?, !str.empty?] when [true, true] format("#{argument} (", str, ')') when [true, false] format(argument) when [false, true] simple_argument?(str) ? "#{str}.as(:arg)" : str else '' end oneliner? ? "#{str}.as(:oneline)" : str end |