Class: Fusuma::Plugin::Events::Records::TouchRecord

Inherits:
Record
  • Object
show all
Defined in:
lib/fusuma/plugin/events/records/touch_record.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status:, finger:, time_offset:, x_px: nil, y_px: nil, x_mm: nil, y_mm: nil) ⇒ TouchRecord

Returns a new instance of TouchRecord.



20
21
22
23
24
25
26
27
28
29
# File 'lib/fusuma/plugin/events/records/touch_record.rb', line 20

def initialize(status:, finger:, time_offset:, x_px: nil, y_px: nil, x_mm: nil, y_mm: nil)
  super()
  @status = status.to_s
  @finger = finger.to_i
  @time_offset = time_offset.to_f
  @x_px = x_px.to_f if x_px
  @y_px = y_px.to_f if y_px
  @x_mm = x_mm.to_f if x_mm
  @y_mm = y_mm.to_f if y_mm
end

Instance Attribute Details

#fingerObject (readonly)

Returns the value of attribute finger.



12
13
14
# File 'lib/fusuma/plugin/events/records/touch_record.rb', line 12

def finger
  @finger
end

#statusObject (readonly)

Returns the value of attribute status.



12
13
14
# File 'lib/fusuma/plugin/events/records/touch_record.rb', line 12

def status
  @status
end

#time_offsetObject (readonly)

Returns the value of attribute time_offset.



12
13
14
# File 'lib/fusuma/plugin/events/records/touch_record.rb', line 12

def time_offset
  @time_offset
end

#x_mmObject (readonly)

Returns the value of attribute x_mm.



12
13
14
# File 'lib/fusuma/plugin/events/records/touch_record.rb', line 12

def x_mm
  @x_mm
end

#x_pxObject (readonly)

Returns the value of attribute x_px.



12
13
14
# File 'lib/fusuma/plugin/events/records/touch_record.rb', line 12

def x_px
  @x_px
end

#y_mmObject (readonly)

Returns the value of attribute y_mm.



12
13
14
# File 'lib/fusuma/plugin/events/records/touch_record.rb', line 12

def y_mm
  @y_mm
end

#y_pxObject (readonly)

Returns the value of attribute y_px.



12
13
14
# File 'lib/fusuma/plugin/events/records/touch_record.rb', line 12

def y_px
  @y_px
end

Instance Method Details

#inspectObject



35
36
37
38
39
40
41
42
# File 'lib/fusuma/plugin/events/records/touch_record.rb', line 35

def inspect
  s = "#{self.class} status: #{status} finger: #{finger} time offset: #{time_offset}"
  s << " x_px: #{x_px}" if x_px
  s << " y_px: #{y_px}" if y_px
  s << " x_mm: #{x_mm}" if x_mm
  s << " y_mm: #{y_mm}" if y_mm
  s
end

#position?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/fusuma/plugin/events/records/touch_record.rb', line 31

def position?
  @x_px || @y_px
end

#to_sObject



44
45
46
# File 'lib/fusuma/plugin/events/records/touch_record.rb', line 44

def to_s
  inspect
end