Class: XMLBuilder::PathParser::Node
- Inherits:
-
Object
- Object
- XMLBuilder::PathParser::Node
- Defined in:
- lib/ec2/amitools/xmlbuilder.rb
Overview
Helper class used by PathParser
Constant Summary collapse
- @@attribute_regex =
Regex for parsing path if the form element@attribute where [index] and @attribute are optional
/^@(\w+)$/
- @@node_regex =
/^(\w+)(?:\[(\d+)\])?(?:@(\w+))?$/
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#element ⇒ Object
readonly
Returns the value of attribute element.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Instance Method Summary collapse
-
#initialize(allow_document, nodes) ⇒ Node
constructor
Nodes is path.split(‘/’).
Constructor Details
#initialize(allow_document, nodes) ⇒ Node
Nodes is path.split(‘/’)
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/ec2/amitools/xmlbuilder.rb', line 99 def initialize(allow_document, nodes) if allow_document && nodes[0] == '' @document = true nodes.shift return end nodes.shift while nodes[0] == '' node = nodes.shift if (match = @@node_regex.match(node)) @element = match[1] @index = match[2].to_i || 0 elsif (match = @@attribute_regex.match(node)) @attribute = match[1] else raise 'Invalid path: Node must be of the form element[index] or @attribute' if document end end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
91 92 93 |
# File 'lib/ec2/amitools/xmlbuilder.rb', line 91 def attribute @attribute end |
#document ⇒ Object (readonly)
Returns the value of attribute document.
88 89 90 |
# File 'lib/ec2/amitools/xmlbuilder.rb', line 88 def document @document end |
#element ⇒ Object (readonly)
Returns the value of attribute element.
89 90 91 |
# File 'lib/ec2/amitools/xmlbuilder.rb', line 89 def element @element end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
90 91 92 |
# File 'lib/ec2/amitools/xmlbuilder.rb', line 90 def index @index end |