Class: CGPoint

Inherits:
Struct
  • Object
show all
Defined in:
lib/mouse.rb,
lib/mouse.rb

Overview

Mouse extensions to CGPoint

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x = 0.0, y = 0.0) ⇒ CGPoint

Returns a new instance of CGPoint.

Parameters:

  • x (Number) (defaults to: 0.0)
  • y (Number) (defaults to: 0.0)


11
12
13
# File 'lib/mouse.rb', line 11

def initialize x = 0.0, y = 0.0
  super x.to_f, y.to_f
end

Instance Attribute Details

#xNumber

The x co-ordinate of the screen point

Returns:

  • (Number)


3
4
5
# File 'lib/mouse.rb', line 3

def x
  @x
end

#yNumber

The y co-ordinate of the screen point

Returns:

  • (Number)


3
4
5
# File 'lib/mouse.rb', line 3

def y
  @y
end

Instance Method Details

#inspectString

Return a nice string representation of the point

Overrides Object#inspect to more closely mimic MacRuby Boxed#inspect.

Returns:

  • (String)


29
30
31
# File 'lib/mouse.rb', line 29

def inspect
  "#<CGPoint x=#{self.x.to_f} y=#{self.y.to_f}>"
end

#to_pointCGPoint

Returns the receiver, since the receiver is already a CGPoint

Returns:



37
38
39
# File 'lib/mouse.rb', line 37

def to_point
  self
end