Class: ICurses::IMouseEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/ektoplayer/ui.rb,
lib/ektoplayer/icurses/sugar.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mouse_event = nil, bstate: nil, x: nil, y: nil, z: nil) ⇒ IMouseEvent

Returns a new instance of IMouseEvent.



5
6
7
8
9
# File 'lib/ektoplayer/icurses/sugar.rb', line 5

def initialize(mouse_event=nil, bstate: nil, x: nil, y: nil, z: nil)
   @x, @y, @z, @bstate = 0, 0, 0, 0
   from_mouse_event!(mouse_event) if mouse_event
   update!(x:x, y:y, z:z, bstate:bstate)
end

Instance Attribute Details

#bstateObject

Returns the value of attribute bstate.



3
4
5
# File 'lib/ektoplayer/icurses/sugar.rb', line 3

def bstate
  @bstate
end

#xObject

Returns the value of attribute x.



3
4
5
# File 'lib/ektoplayer/icurses/sugar.rb', line 3

def x
  @x
end

#yObject

Returns the value of attribute y.



3
4
5
# File 'lib/ektoplayer/icurses/sugar.rb', line 3

def y
  @y
end

#zObject

Returns the value of attribute z.



3
4
5
# File 'lib/ektoplayer/icurses/sugar.rb', line 3

def z
  @z
end

Instance Method Details

#[](key) ⇒ Object



11
# File 'lib/ektoplayer/icurses/sugar.rb', line 11

def [](key)          send(key)               end

#[]=(key, value) ⇒ Object



12
# File 'lib/ektoplayer/icurses/sugar.rb', line 12

def []=(key, value)  send("#{key}=", value)  end

#from_mouse_event!(m) ⇒ Object



14
15
16
17
18
# File 'lib/ektoplayer/icurses/sugar.rb', line 14

def from_mouse_event!(m)
   @x, @y, @z, @bstate = m.x, m.y, m.z, m.bstate 
rescue
   @x, @y, @z, @bstate = m[:x], m[:y], m[:z], m[:bstate]
end

#posObject



347
348
349
# File 'lib/ektoplayer/ui.rb', line 347

def pos
   UI::Point.new(x: x, y: y)
end

#to_fakeObject



351
352
353
# File 'lib/ektoplayer/ui.rb', line 351

def to_fake
   IMouseEvent.new(self)
end

#to_sObject



355
356
357
# File 'lib/ektoplayer/ui.rb', line 355

def to_s
   "[(IMouseEvent) bstate=#{bstate}, x=#{x}, y=#{y}, z=#{z}]"
end

#update!(x: nil, y: nil, z: nil, bstate: nil) ⇒ Object



20
21
22
23
24
25
# File 'lib/ektoplayer/icurses/sugar.rb', line 20

def update!(x: nil, y: nil, z: nil, bstate: nil)
   @x = x if x
   @y = y if y
   @z = z if z
   @bstate = bstate if bstate
end