Class: Gdk::Rectangle

Inherits:
Object
  • Object
show all
Defined in:
lib/gdk3/rectangle.rb

Instance Method Summary collapse

Constructor Details

#initialize(x, y, width, height) ⇒ Rectangle

Returns a new instance of Rectangle.



20
21
22
23
24
25
26
# File 'lib/gdk3/rectangle.rb', line 20

def initialize(x, y, width, height)
  initialize_raw
  self.x = x
  self.y = y
  self.width = width
  self.height = height
end

Instance Method Details

#==(other) ⇒ Object



50
51
52
53
# File 'lib/gdk3/rectangle.rb', line 50

def ==(other)
  other.is_a?(self.class) and
    self.to_a == other.to_a
end

#initialize_rawObject



19
# File 'lib/gdk3/rectangle.rb', line 19

alias_method :initialize_raw, :initialize

#inspectObject



38
39
40
41
42
43
# File 'lib/gdk3/rectangle.rb', line 38

def inspect
  super.gsub(/>\z/) do
    " x=#{x.inspect} y=#{y.inspect} " +
      "width=#{width.inspect} height=#{height.inspect}>"
  end
end

#intersect(other) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/gdk3/rectangle.rb', line 29

def intersect(other)
  intersected, dest = intersect_raw(other)
  if intersected
    dest
  else
    nil
  end
end

#intersect_rawObject



28
# File 'lib/gdk3/rectangle.rb', line 28

alias_method :intersect_raw, :intersect

#to_aObject



45
46
47
# File 'lib/gdk3/rectangle.rb', line 45

def to_a
  [x, y, width, height]
end