Class: Dommy::DOMRect

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(x: 0, y: 0, width: 0, height: 0) ⇒ DOMRect

Returns a new instance of DOMRect.



1036
1037
1038
1039
1040
1041
# File 'lib/dommy/element.rb', line 1036

def initialize(x: 0, y: 0, width: 0, height: 0)
  @x = x
  @y = y
  @width = width
  @height = height
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



1034
1035
1036
# File 'lib/dommy/element.rb', line 1034

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width.



1034
1035
1036
# File 'lib/dommy/element.rb', line 1034

def width
  @width
end

#xObject (readonly)

Returns the value of attribute x.



1034
1035
1036
# File 'lib/dommy/element.rb', line 1034

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



1034
1035
1036
# File 'lib/dommy/element.rb', line 1034

def y
  @y
end

Instance Method Details

#__js_get__(key) ⇒ Object



1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
# File 'lib/dommy/element.rb', line 1059

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
  else
    Bridge::ABSENT
  end
end

#bottomObject



1055
1056
1057
# File 'lib/dommy/element.rb', line 1055

def bottom
  @y + @height
end

#js_null?Boolean

Returns:

  • (Boolean)


1078
1079
1080
# File 'lib/dommy/element.rb', line 1078

def js_null?
  false
end

#leftObject



1047
1048
1049
# File 'lib/dommy/element.rb', line 1047

def left
  @x
end

#rightObject



1051
1052
1053
# File 'lib/dommy/element.rb', line 1051

def right
  @x + @width
end

#topObject



1043
1044
1045
# File 'lib/dommy/element.rb', line 1043

def top
  @y
end