Class: Gammo::XPath::AST::NodeTest::Name
- Inherits:
-
Gammo::XPath::AST::NodeTest
- Object
- Gammo::XPath::AST::NodeTest
- Gammo::XPath::AST::NodeTest::Name
- Defined in:
- lib/gammo/xpath/ast/node_test.rb
Constant Summary
Constants included from Subclassify
Instance Attribute Summary collapse
-
#local ⇒ Object
readonly
Returns the value of attribute local.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
Instance Method Summary collapse
-
#initialize(local: nil, namespace: nil) ⇒ Name
constructor
A new instance of Name.
- #match?(node) ⇒ Boolean
- #xml_namespace? ⇒ Boolean
Constructor Details
#initialize(local: nil, namespace: nil) ⇒ Name
Returns a new instance of Name.
20 21 22 23 |
# File 'lib/gammo/xpath/ast/node_test.rb', line 20 def initialize(local: nil, namespace: nil) @local = local @namespace = namespace end |
Instance Attribute Details
#local ⇒ Object (readonly)
Returns the value of attribute local.
18 19 20 |
# File 'lib/gammo/xpath/ast/node_test.rb', line 18 def local @local end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
18 19 20 |
# File 'lib/gammo/xpath/ast/node_test.rb', line 18 def namespace @namespace end |
Instance Method Details
#match?(node) ⇒ Boolean
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/gammo/xpath/ast/node_test.rb', line 29 def match?(node) return false unless node return false if xml_namespace? return !namespace || namespace == node.namespace if local == ?* # TODO: investigate if node.instance_of?(Gammo::Attribute) # TODO: need to work node.key == local && node.namespace == namespace else if document = node.owner_document # TODO: ignoring ascii case return node.tag == local && (!namespace || node.namespace == namespace) if node.instance_of?(Gammo::Node::Element) return node.tag == local && node.namespace == namespace && namespace end node.tag == local && node.namespace == namespace end end |
#xml_namespace? ⇒ Boolean
25 26 27 |
# File 'lib/gammo/xpath/ast/node_test.rb', line 25 def xml_namespace? namespace == 'http://www.w3.org/XML/1998/namespace' end |