Class: Dommy::DOMRect
- Inherits:
-
Object
- Object
- Dommy::DOMRect
- Defined in:
- lib/dommy/element.rb
Overview
Stub ‘DOMRect` for `getBoundingClientRect` — no layout engine, so all values are 0. Consumer code that uses these for relative positioning sees zeroed values; absolute layout assertions need the real browser.
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
- #__js_get__(key) ⇒ Object
- #bottom ⇒ Object
-
#initialize(x: 0, y: 0, width: 0, height: 0) ⇒ DOMRect
constructor
A new instance of DOMRect.
- #js_null? ⇒ Boolean
- #left ⇒ Object
- #right ⇒ Object
- #top ⇒ Object
Constructor Details
#initialize(x: 0, y: 0, width: 0, height: 0) ⇒ DOMRect
Returns a new instance of DOMRect.
496 497 498 499 500 501 |
# File 'lib/dommy/element.rb', line 496 def initialize(x: 0, y: 0, width: 0, height: 0) @x = x @y = y @width = width @height = height end |
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height.
494 495 496 |
# File 'lib/dommy/element.rb', line 494 def height @height end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
494 495 496 |
# File 'lib/dommy/element.rb', line 494 def width @width end |
#x ⇒ Object (readonly)
Returns the value of attribute x.
494 495 496 |
# File 'lib/dommy/element.rb', line 494 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
494 495 496 |
# File 'lib/dommy/element.rb', line 494 def y @y end |
Instance Method Details
#__js_get__(key) ⇒ Object
519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 |
# File 'lib/dommy/element.rb', line 519 def __js_get__(key) case key when "x", "left" @x when "y", "top" @y when "width" @width when "height" @height when "right" @x + @width when "bottom" @y + @height end end |
#bottom ⇒ Object
515 516 517 |
# File 'lib/dommy/element.rb', line 515 def bottom @y + @height end |
#js_null? ⇒ Boolean
536 537 538 |
# File 'lib/dommy/element.rb', line 536 def js_null? false end |
#left ⇒ Object
507 508 509 |
# File 'lib/dommy/element.rb', line 507 def left @x end |
#right ⇒ Object
511 512 513 |
# File 'lib/dommy/element.rb', line 511 def right @x + @width end |
#top ⇒ Object
503 504 505 |
# File 'lib/dommy/element.rb', line 503 def top @y end |