Class: OSX::NSPoint

Inherits:
Object show all
Defined in:
src/ruby/osx/objc/oc_types.rb

Overview

NSPoint additions.

Examples:

point = OSX::NSPoint.new(42, 24)
=> #<OSX::NSPoint x=42.0, y=24.0>
point.in? OSX::NSRect.new(40, 20, 2, 1) # x, y, w, h
=> false
point.in? OSX::NSRect.new(40, 20, 3, 2)
=> true

Instance Method Summary (collapse)

Instance Method Details

- (Object) +(v)



87
88
89
90
91
92
93
# File 'src/ruby/osx/objc/oc_types.rb', line 87

def +(v)
  if v.is_a?(OSX::NSSize)
    OSX::NSPoint.new(x + v.width, y + v.height)
  else
    raise ArgumentException, "parameter should be NSSize"
  end
end

- (Object) -(v)



94
95
96
97
98
99
100
# File 'src/ruby/osx/objc/oc_types.rb', line 94

def -(v)
  if v.is_a?(OSX::NSSize)
    OSX::NSPoint.new(x - v.width, y - v.height)
  else
    raise ArgumentException, "parameter should be NSSize"
  end
end

- (Boolean) in?(rect) Also known as: inRect?

Returns:

  • (Boolean)


85
# File 'src/ruby/osx/objc/oc_types.rb', line 85

def in?(rect); OSX::NSPointInRect(self, rect); end

- (Object) inspect



101
# File 'src/ruby/osx/objc/oc_types.rb', line 101

def inspect; "#<#{self.class} x=#{x}, y=#{y}>"; end