Class: Net::VNC::PointerState

Inherits:
Object
  • Object
show all
Defined in:
lib/net/vnc.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vnc) ⇒ PointerState

Returns a new instance of PointerState.



33
34
35
36
# File 'lib/net/vnc.rb', line 33

def initialize(vnc)
  @x = @y = @button = 0
  @vnc = vnc
end

Instance Attribute Details

#buttonObject

Returns the value of attribute button.



31
32
33
# File 'lib/net/vnc.rb', line 31

def button
  @button
end

#xObject (readonly)

Returns the value of attribute x.



31
32
33
# File 'lib/net/vnc.rb', line 31

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



31
32
33
# File 'lib/net/vnc.rb', line 31

def y
  @y
end

Instance Method Details

#refreshObject



51
52
53
54
55
56
57
58
# File 'lib/net/vnc.rb', line 51

def refresh
  packet = 0.chr * 6
  packet[0] = 5.chr
  packet[1] = button.chr
  packet[2, 2] = [x].pack 'n'
  packet[4, 2] = [y].pack 'n'
  @vnc.socket.write packet
end

#update(x, y, button = @button) ⇒ Object



44
45
46
47
48
49
# File 'lib/net/vnc.rb', line 44

def update(x, y, button = @button)
  @x = x
  @y = y
  @button = button
  refresh
end