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
- #ancestors ⇒ Object
- #attribute(name) ⇒ Object
- #content ⇒ Object
- #css_path ⇒ Object
- #element_by_id(id) ⇒ Object
- #element_by_xpath(xpath) ⇒ Object
- #elements_by_css(*rules) ⇒ Object
- #elements_by_xpath(*xpaths) ⇒ Object
-
#initialize(element) ⇒ Element
constructor
A new instance of Element.
- #inner_html ⇒ Object
- #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
64 65 66 |
# File 'lib/locator/dom/nokogiri/element.rb', line 64 def ancestor_of?(other) other.ancestors.include?(element) end |
#ancestors ⇒ Object
60 61 62 |
# File 'lib/locator/dom/nokogiri/element.rb', line 60 def ancestors element.ancestors end |
#attribute(name) ⇒ Object
40 41 42 |
# File 'lib/locator/dom/nokogiri/element.rb', line 40 def attribute(name) element.attribute(name).to_s end |
#content ⇒ Object
28 29 30 |
# File 'lib/locator/dom/nokogiri/element.rb', line 28 def content element.content end |
#css_path ⇒ Object
24 25 26 |
# File 'lib/locator/dom/nokogiri/element.rb', line 24 def css_path element.css_path.to_s end |
#element_by_id(id) ⇒ Object
44 45 46 |
# File 'lib/locator/dom/nokogiri/element.rb', line 44 def element_by_id(id) elements_by_xpath("//*[@id='#{id}']").first end |
#element_by_xpath(xpath) ⇒ Object
48 49 50 |
# File 'lib/locator/dom/nokogiri/element.rb', line 48 def element_by_xpath(xpath) elements_by_xpath(xpath).first end |
#elements_by_css(*rules) ⇒ Object
56 57 58 |
# File 'lib/locator/dom/nokogiri/element.rb', line 56 def elements_by_css(*rules) element.css(*rules).map { |element| Element.new(element) } end |
#elements_by_xpath(*xpaths) ⇒ Object
52 53 54 |
# File 'lib/locator/dom/nokogiri/element.rb', line 52 def elements_by_xpath(*xpaths) element.xpath(*xpaths).map { |element| Element.new(element) } end |
#inner_html ⇒ Object
32 33 34 |
# File 'lib/locator/dom/nokogiri/element.rb', line 32 def inner_html element.inner_html end |
#name ⇒ Object
16 17 18 |
# File 'lib/locator/dom/nokogiri/element.rb', line 16 def name element.name end |
#to_s ⇒ Object
36 37 38 |
# File 'lib/locator/dom/nokogiri/element.rb', line 36 def to_s element.to_s end |
#xpath ⇒ Object
20 21 22 |
# File 'lib/locator/dom/nokogiri/element.rb', line 20 def xpath element.path.to_s end |