Class: RSpecHTML::Element
- Inherits:
-
Object
- Object
- RSpecHTML::Element
- Extended by:
- Forwardable
- Defined in:
- lib/rspec_html/element.rb
Overview
HTML DOM element abstraction
Instance Attribute Summary collapse
-
#element ⇒ Object
readonly
Returns the value of attribute element.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(element, name, options: {}, siblings: []) ⇒ Element
constructor
A new instance of Element.
- #inspect ⇒ Object
- #present? ⇒ Boolean (also: #exist?)
- #reconstituted ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(element, name, options: {}, siblings: []) ⇒ Element
Returns a new instance of Element.
13 14 15 16 17 18 19 |
# File 'lib/rspec_html/element.rb', line 13 def initialize(element, name, options: {}, siblings: []) @name = name @element = element @options = @siblings = siblings @search = Search.new(@element, @siblings) end |
Instance Attribute Details
#element ⇒ Object (readonly)
Returns the value of attribute element.
6 7 8 |
# File 'lib/rspec_html/element.rb', line 6 def element @element end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/rspec_html/element.rb', line 6 def name @name end |
Class Method Details
.reconstituted(tag, options = {}) ⇒ Object
49 50 51 |
# File 'lib/rspec_html/element.rb', line 49 def self.reconstituted(tag, = {}) ReconstitutedElement.new(tag, ).to_s end |
Instance Method Details
#inspect ⇒ Object
28 29 30 |
# File 'lib/rspec_html/element.rb', line 28 def inspect "<#{self.class}::#{name.to_s.capitalize}>" end |
#present? ⇒ Boolean Also known as: exist?
21 22 23 24 25 |
# File 'lib/rspec_html/element.rb', line 21 def present? return true if name == :document @search.present? end |
#reconstituted ⇒ Object
45 46 47 |
# File 'lib/rspec_html/element.rb', line 45 def reconstituted self.class.reconstituted(name, @options) end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/rspec_html/element.rb', line 32 def to_s @element.to_s end |