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: 0, x: 0, y: 0, z: 0) ⇒ IMouseEvent

Returns a new instance of IMouseEvent.



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

def initialize(mouse_event=nil, bstate: 0, x: 0, y: 0, z: 0)
   @x, @y, @z, @bstate = x, y, z, bstate
   from_mouse_event!(mouse_event)
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



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

def [](key)          send(key)               end

#[]=(key, value) ⇒ Object



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

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

#from_mouse_event!(m) ⇒ Object



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

def from_mouse_event!(m)
   @x, @y, @z, @bstate = m.x, m.y, m.z, m.bstate 
rescue
   begin @x, @y, @z, @bstate = m[:x], m[:y], m[:z], m[:bstate]
   rescue
   end
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



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

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