Class: DotDiff::ElementMeta::Rectangle

Inherits:
Object
  • Object
show all
Defined in:
lib/dotdiff/element_meta.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page, xpath) ⇒ Rectangle

Returns a new instance of Rectangle.



17
18
19
# File 'lib/dotdiff/element_meta.rb', line 17

def initialize(page, xpath)
  @rect = get_rect(page, xpath)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dotdiff/element_meta.rb', line 21

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

Instance Attribute Details

#rectObject (readonly)

Returns the value of attribute rect.



15
16
17
# File 'lib/dotdiff/element_meta.rb', line 15

def rect
  @rect
end