Class: Win32::CaptureIE::Area

Inherits:
Object
  • Object
show all
Defined in:
lib/win32/capture_ie/area.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y, w, h) ⇒ Area

Returns a new instance of Area.



13
14
15
# File 'lib/win32/capture_ie/area.rb', line 13

def initialize(x, y, w, h)
  @x, @y, @w, @h = x, y, w, h
end

Instance Attribute Details

#hObject Also known as: height

Returns the value of attribute h.



7
8
9
# File 'lib/win32/capture_ie/area.rb', line 7

def h
  @h
end

#wObject Also known as: width

Returns the value of attribute w.



7
8
9
# File 'lib/win32/capture_ie/area.rb', line 7

def w
  @w
end

#xObject Also known as: x1

Returns the value of attribute x.



7
8
9
# File 'lib/win32/capture_ie/area.rb', line 7

def x
  @x
end

#yObject Also known as: y1

Returns the value of attribute y.



7
8
9
# File 'lib/win32/capture_ie/area.rb', line 7

def y
  @y
end

Instance Method Details

#+(other) ⇒ Object



45
46
47
48
49
# File 'lib/win32/capture_ie/area.rb', line 45

def +(other)
  tl = top_left.zip(other.top_left).map{|e| e.min }
  br = bottom_right.zip(other.bottom_right).map{|e| e.max }
  self.class.new(tl[0], tl[1], br[0] - tl[0], br[1] - tl[1])
end

#bottom_leftObject



33
34
35
# File 'lib/win32/capture_ie/area.rb', line 33

def bottom_left
  [x1, y2]
end

#bottom_rightObject



37
38
39
# File 'lib/win32/capture_ie/area.rb', line 37

def bottom_right
  [x2, y2]
end

#rectObject



41
42
43
# File 'lib/win32/capture_ie/area.rb', line 41

def rect
  [x1, y1, x2, y2]
end

#to_sObject



51
52
53
# File 'lib/win32/capture_ie/area.rb', line 51

def to_s
  "[(%d, %d), (%d, %d)]" % rect
end

#top_leftObject



25
26
27
# File 'lib/win32/capture_ie/area.rb', line 25

def top_left
  [x1, y1]
end

#top_rightObject



29
30
31
# File 'lib/win32/capture_ie/area.rb', line 29

def top_right
  [x2, y1]
end

#x2Object



17
18
19
# File 'lib/win32/capture_ie/area.rb', line 17

def x2
  x + w
end

#y2Object



21
22
23
# File 'lib/win32/capture_ie/area.rb', line 21

def y2
  y + h
end