Class: SDL2::Rect

Inherits:
Struct
  • Object
show all
Defined in:
lib/sdl2/rect.rb

Instance Method Summary collapse

Methods inherited from Struct

#==, #initialize, #inspect, member_readers, member_writers, release

Constructor Details

This class inherits a constructor from SDL2::Struct

Instance Method Details

#emptyObject Also known as: empty?



14
15
16
# File 'lib/sdl2/rect.rb', line 14

def empty
  return ((!self.null?) || (self[:w] <= 0) || (self[:h] <= 0))
end

#equals(other) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sdl2/rect.rb', line 20

def equals(other)    
  return false if other.nil?
  return false unless other.kind_of? Rect
  
  if self.null? or other.null? # Either null?
    return (self.null? and other.null?) # Equal if both are null!      
  else
    members.each do |field| # Compare our fields.
      return false unless self[field] == other[field]
    end
  end
  return true # if we made it this far
end