class DotDiff::ElementMeta::Rectangle
Attributes
rect[R]
Public Class Methods
new(page, xpath)
click to toggle source
# File lib/dotdiff/element_meta.rb, line 19 def initialize(page, xpath) @rect = get_rect(page, xpath) end
Public Instance Methods
method_missing(name, *args, &block)
click to toggle source
Calls superclass method
# File lib/dotdiff/element_meta.rb, line 23 def method_missing(name, *args, &block) if %w[x y width height].include?(name.to_s) case name when :x then rect['left'] when :y then rect['top'] else rect[name.to_s] end else super end end
respond_to_missing?(name, _include_private = false)
click to toggle source
Calls superclass method
# File lib/dotdiff/element_meta.rb, line 35 def respond_to_missing?(name, _include_private = false) %w[x y width height].include?(name.to_s) || super end
Private Instance Methods
get_rect(page, xpath)
click to toggle source
# File lib/dotdiff/element_meta.rb, line 46 def get_rect(page, xpath) page.evaluate_script(js_query(xpath)) end
js_query(xpath)
click to toggle source
# File lib/dotdiff/element_meta.rb, line 41 def js_query(xpath) "document.evaluate(\"#{xpath}\", document, null, XPathResult."\ 'FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.getBoundingClientRect()' end