Class: Locator::Dom::Nokogiri::Element
- Inherits:
-
Object
- Object
- Locator::Dom::Nokogiri::Element
- Defined in:
- lib/locator/dom/nokogiri/element.rb
Instance Attribute Summary collapse
-
#element ⇒ Object
readonly
Returns the value of attribute element.
-
#matches ⇒ Object
readonly
Returns the value of attribute matches.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #ancestor_of?(other) ⇒ Boolean
- #attribute(name) ⇒ Object
- #attributes(names) ⇒ Object
- #content ⇒ Object
- #css_path ⇒ Object
- #elements_by_xpath(xpath) ⇒ Object
-
#initialize(element) ⇒ Element
constructor
A new instance of Element.
- #inner_html ⇒ Object
- #tag_name ⇒ Object
- #to_s ⇒ Object
- #xpath ⇒ Object
Constructor Details
#initialize(element) ⇒ Element
Returns a new instance of Element.
7 8 9 10 |
# File 'lib/locator/dom/nokogiri/element.rb', line 7 def initialize(element) @element = element @matches = [] end |
Instance Attribute Details
#element ⇒ Object (readonly)
Returns the value of attribute element.
5 6 7 |
# File 'lib/locator/dom/nokogiri/element.rb', line 5 def element @element end |
#matches ⇒ Object (readonly)
Returns the value of attribute matches.
5 6 7 |
# File 'lib/locator/dom/nokogiri/element.rb', line 5 def matches @matches end |
Instance Method Details
#<=>(other) ⇒ Object
12 13 14 |
# File 'lib/locator/dom/nokogiri/element.rb', line 12 def <=>(other) to_s.length <=> other.to_s.length end |
#ancestor_of?(other) ⇒ Boolean
40 41 42 |
# File 'lib/locator/dom/nokogiri/element.rb', line 40 def ancestor_of?(other) other.element.ancestors.include?(element) end |
#attribute(name) ⇒ Object
44 45 46 |
# File 'lib/locator/dom/nokogiri/element.rb', line 44 def attribute(name) element.attribute(name).to_s end |
#attributes(names) ⇒ Object
48 49 50 |
# File 'lib/locator/dom/nokogiri/element.rb', line 48 def attributes(names) names.map { |name| attribute(name) } end |
#content ⇒ Object
24 25 26 |
# File 'lib/locator/dom/nokogiri/element.rb', line 24 def content element.content end |
#css_path ⇒ Object
20 21 22 |
# File 'lib/locator/dom/nokogiri/element.rb', line 20 def css_path element.css_path.to_s end |
#elements_by_xpath(xpath) ⇒ Object
52 53 54 |
# File 'lib/locator/dom/nokogiri/element.rb', line 52 def elements_by_xpath(xpath) element.xpath(xpath).map { |element| Element.new(element) } end |
#inner_html ⇒ Object
28 29 30 |
# File 'lib/locator/dom/nokogiri/element.rb', line 28 def inner_html element.inner_html end |
#tag_name ⇒ Object
36 37 38 |
# File 'lib/locator/dom/nokogiri/element.rb', line 36 def tag_name element.description.name end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/locator/dom/nokogiri/element.rb', line 32 def to_s element.to_s end |
#xpath ⇒ Object
16 17 18 |
# File 'lib/locator/dom/nokogiri/element.rb', line 16 def xpath element.path.to_s end |