Class: Junoser::Xsd::SimpleContent

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/junoser/xsd/simple_content.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

#configObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/junoser/xsd/simple_content.rb', line 9

def config
  @config ||= children.map {|child|
    case child.name
    when 'restriction'
      Junoser::Xsd::Restriction.new(child, depth: @depth+1, parent: self)
    when 'extension'
      'arg'
    else
      raise "ERROR: unknown element: #{child.name}"
    end
  }
end

#to_sObject



22
23
24
25
26
27
28
# File 'lib/junoser/xsd/simple_content.rb', line 22

def to_s
  return if config.empty?
  raise "ERROR: simpleContent shouldn't have multiple children" if config.size > 1

  child = config.first
  child.is_a?(String) ? format(OFFSET + child) : child.to_s
end