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.
4 5 6 |
# File 'lib/junoser/xsd/base.rb', line 4 def parent @parent end |
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
4 5 6 |
# File 'lib/junoser/xsd/base.rb', line 4 def xml @xml end |
Instance Method Details
#children ⇒ Object
18 19 20 |
# File 'lib/junoser/xsd/base.rb', line 18 def children @children||= xml.xpath('./*[not(self::xsd:annotation)]') end |
#config ⇒ Object
14 15 16 |
# File 'lib/junoser/xsd/base.rb', line 14 def config raise "ERROR: no implementation" end |
#initialize(xml, options = {}) ⇒ Object
8 9 10 11 12 |
# File 'lib/junoser/xsd/base.rb', line 8 def initialize(xml, ={}) @xml = xml @depth = [:depth] || 0 @parent = [:parent] end |
#inspect ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/junoser/xsd/base.rb', line 26 def inspect ["#<#{self.class}:0x#{object_id}", "xml=#{xml.namespace.prefix}:#{xml.name}" << " attributes=" << Hash[xml.attributes.map {|k, v| [k, v.value] }].to_s << (respond_to?(:label) ? " label=#{label}" : ''), "config=[", *config.map {|c| c.inspect }, ']>'].join("\n#{OFFSET*(@depth+1)}") end |
#oneliner? ⇒ Boolean
36 37 38 39 |
# File 'lib/junoser/xsd/base.rb', line 36 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
22 23 24 |
# File 'lib/junoser/xsd/base.rb', line 22 def root? @depth == 1 end |