Module: Junoser::Xsd::Base
- Included in:
- Choice, ComplexType, Element, Enumeration, Restriction, Sequence, SimpleContent, SimpleType, Union
- Defined in:
- lib/junoser/xsd/base.rb
Constant Summary collapse
- OFFSET =
' '
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Instance Method Summary collapse
- #children ⇒ Object
- #config ⇒ Object
- #initialize(xml, options = {}) ⇒ Object
- #inspect ⇒ Object
- #oneliner? ⇒ Boolean
- #root? ⇒ Boolean
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
6 7 8 |
# File 'lib/junoser/xsd/base.rb', line 6 def parent @parent end |
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
6 7 8 |
# File 'lib/junoser/xsd/base.rb', line 6 def xml @xml end |
Instance Method Details
#children ⇒ Object
20 21 22 |
# File 'lib/junoser/xsd/base.rb', line 20 def children @children ||= xml.xpath('./*[not(self::xsd:annotation)]') end |
#config ⇒ Object
16 17 18 |
# File 'lib/junoser/xsd/base.rb', line 16 def config raise 'ERROR: no implementation' end |
#initialize(xml, options = {}) ⇒ Object
10 11 12 13 14 |
# File 'lib/junoser/xsd/base.rb', line 10 def initialize(xml, = {}) @xml = xml @depth = [:depth] || 0 @parent = [:parent] end |
#inspect ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/junoser/xsd/base.rb', line 28 def inspect ["#<#{self.class}:0x#{object_id}", "xml=#{xml.namespace.prefix}:#{xml.name} " \ "attributes=#{xml.attributes.transform_values(&:value)}" << (respond_to?(:label) ? " label=#{label}" : ''), 'config=[', *config.map(&:inspect), ']>'].join("\n#{OFFSET * (@depth + 1)}") end |
#oneliner? ⇒ Boolean
38 39 40 41 |
# File 'lib/junoser/xsd/base.rb', line 38 def oneliner? # don't use "/flag" as xsd manipulation automatically add "xsd:" prefix @oneliner ||= !xml.xpath('./xsd:annotation/xsd:appinfo/*[local-name()="flag" and text()="oneliner"]').empty? end |
#root? ⇒ Boolean
24 25 26 |
# File 'lib/junoser/xsd/base.rb', line 24 def root? @depth == 1 end |