Class: Fluentxpath::XPath
- Inherits:
-
Object
- Object
- Fluentxpath::XPath
- Defined in:
- lib/fluentxpath.rb
Instance Attribute Summary collapse
-
#expression ⇒ Object
Returns the value of attribute expression.
Class Method Summary collapse
Instance Method Summary collapse
- #and_attribute(attributes) ⇒ Object
- #and_attributes(attributes) ⇒ Object
- #and_name(name) ⇒ Object
- #and_then ⇒ Object
-
#initialize ⇒ XPath
constructor
A new instance of XPath.
- #to_any_element ⇒ Object
- #to_children ⇒ Object
- #to_descendants ⇒ Object
- #to_root_element ⇒ Object
- #to_root_node ⇒ Object
- #with_attribute(attributes) ⇒ Object
- #with_attributes(attributes) ⇒ Object
- #with_name(name) ⇒ Object
Constructor Details
#initialize ⇒ XPath
16 17 18 |
# File 'lib/fluentxpath.rb', line 16 def initialize @expression = "" end |
Instance Attribute Details
#expression ⇒ Object
Returns the value of attribute expression.
8 9 10 |
# File 'lib/fluentxpath.rb', line 8 def expression @expression end |
Class Method Details
.that_navigates(&block) ⇒ Object
10 11 12 13 14 |
# File 'lib/fluentxpath.rb', line 10 def self.that_navigates(&block) xpath = self.new xpath.instance_eval(&block) return xpath.expression end |
Instance Method Details
#and_attribute(attributes) ⇒ Object
62 63 64 |
# File 'lib/fluentxpath.rb', line 62 def and_attribute(attributes) with_attributes(attributes) end |
#and_attributes(attributes) ⇒ Object
58 59 60 |
# File 'lib/fluentxpath.rb', line 58 def and_attributes(attributes) with_attributes(attributes) end |
#and_name(name) ⇒ Object
36 37 38 |
# File 'lib/fluentxpath.rb', line 36 def and_name(name) with_name(name) end |
#and_then ⇒ Object
40 41 42 |
# File 'lib/fluentxpath.rb', line 40 def and_then return self end |
#to_any_element ⇒ Object
28 29 30 |
# File 'lib/fluentxpath.rb', line 28 def to_any_element add "//" end |
#to_children ⇒ Object
44 45 46 |
# File 'lib/fluentxpath.rb', line 44 def to_children add "/" end |
#to_descendants ⇒ Object
48 49 50 |
# File 'lib/fluentxpath.rb', line 48 def to_descendants add "//" end |
#to_root_element ⇒ Object
24 25 26 |
# File 'lib/fluentxpath.rb', line 24 def to_root_element add "/" end |
#to_root_node ⇒ Object
20 21 22 |
# File 'lib/fluentxpath.rb', line 20 def to_root_node add "/" end |
#with_attribute(attributes) ⇒ Object
66 67 68 |
# File 'lib/fluentxpath.rb', line 66 def with_attribute(attributes) with_attributes(attributes) end |
#with_attributes(attributes) ⇒ Object
52 53 54 55 56 |
# File 'lib/fluentxpath.rb', line 52 def with_attributes(attributes) predicates = [] attributes.each_pair { |attribute, value| predicates << "@#{attribute}='#{value}'" } add "[#{predicates.sort.join(" and ")}]" end |
#with_name(name) ⇒ Object
32 33 34 |
# File 'lib/fluentxpath.rb', line 32 def with_name(name) add name end |