Class: SDL2::Rect
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Struct
#==, #initialize, release
#member_readers, #member_writers
Constructor Details
This class inherits a constructor from SDL2::Struct
Class Method Details
.cast(something) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/sdl2/rect.rb', line 14
def self.cast(something)
if something.kind_of?(Array)
something.map!(&:to_i)
result = Rect.new
case something.count
when 4
result.x, result.y, result.w, result.h = something
when 2
result.x, result.y = something
else
raise "#{self}#cast cannot convert array length #{something.count} of: #{something.inspect}"
end
return result
else
return super
end
end
|
Instance Method Details
#empty ⇒ Object
Also known as:
empty?
33
34
35
|
# File 'lib/sdl2/rect.rb', line 33
def empty
return ((!self.null?) || (self[:w] <= 0) || (self[:h] <= 0))
end
|
#equals(other) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/sdl2/rect.rb', line 39
def equals(other)
return false if other.nil?
return false unless other.kind_of? Rect
if self.null? or other.null? return (self.null? and other.null?) else
members.each do |field| return false unless self[field] == other[field]
end
end
return true end
|