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.



19
20
21
# File 'lib/dotdiff/element_meta.rb', line 19

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



23
24
25
26
27
28
29
30
31
32
33
# 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

Instance Attribute Details

#rectObject (readonly)

Returns the value of attribute rect.



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

def rect
  @rect
end

Instance Method Details

#respond_to_missing?(name, _include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# 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