Class: Rubydraw::MouseState

Inherits:
Object show all
Defined in:
lib/rubydraw/mouse_state.rb

Overview

An instance of this class is returned every time you call Rubydraw.mouse_state.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(button, position) ⇒ MouseState

Returns a new instance of MouseState.



7
8
9
# File 'lib/rubydraw/mouse_state.rb', line 7

def initialize(button, position)
  @button, @position = button, position
end

Instance Attribute Details

#buttonObject (readonly)

Returns the value of attribute button.



5
6
7
# File 'lib/rubydraw/mouse_state.rb', line 5

def button
  @button
end

#positionObject (readonly)

Returns the value of attribute position.



5
6
7
# File 'lib/rubydraw/mouse_state.rb', line 5

def position
  @position
end

Instance Method Details

#to_aryObject



19
20
21
# File 'lib/rubydraw/mouse_state.rb', line 19

def to_ary
  [@button, x, y]
end

#xObject



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

def x
  @position.x
end

#yObject



15
16
17
# File 'lib/rubydraw/mouse_state.rb', line 15

def y
  @position.y
end