Class: Celerity::Identifier
- Inherits:
-
Object
- Object
- Celerity::Identifier
- Defined in:
- lib/celerity/identifier.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(tag, attributes = {}) ⇒ Identifier
constructor
A new instance of Identifier.
- #match?(element) ⇒ Boolean
Constructor Details
#initialize(tag, attributes = {}) ⇒ Identifier
Returns a new instance of Identifier.
7 8 9 10 11 |
# File 'lib/celerity/identifier.rb', line 7 def initialize(tag, attributes = {}) @tag = tag @attributes = attributes @text = nil end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/celerity/identifier.rb', line 5 def attributes @attributes end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
5 6 7 |
# File 'lib/celerity/identifier.rb', line 5 def tag @tag end |
#text ⇒ Object
Returns the value of attribute text.
4 5 6 |
# File 'lib/celerity/identifier.rb', line 4 def text @text end |
Instance Method Details
#match?(element) ⇒ Boolean
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/celerity/identifier.rb', line 13 def match?(element) return false unless @tag == element.getTagName attr_result = @attributes.all? do |key, values| values.any? { |val| Util.matches?(element.getAttribute(key.to_s), val) } end if @text attr_result && Util.matches?(element.asText.strip, @text) else attr_result end end |