Class: DevInput::Event
- Inherits:
-
Struct
- Object
- Struct
- DevInput::Event
- Defined in:
- lib/libdevinput.rb,
lib/libdevinput.rb
Overview
open Event class and add some convenience methods
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#tv_sec ⇒ Object
Returns the value of attribute tv_sec.
-
#tv_usec ⇒ Object
Returns the value of attribute tv_usec.
-
#type ⇒ Object
Returns the value of attribute type.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code
463 464 465 |
# File 'lib/libdevinput.rb', line 463 def code @code end |
#tv_sec ⇒ Object
Returns the value of attribute tv_sec
463 464 465 |
# File 'lib/libdevinput.rb', line 463 def tv_sec @tv_sec end |
#tv_usec ⇒ Object
Returns the value of attribute tv_usec
463 464 465 |
# File 'lib/libdevinput.rb', line 463 def tv_usec @tv_usec end |
#type ⇒ Object
Returns the value of attribute type
463 464 465 |
# File 'lib/libdevinput.rb', line 463 def type @type end |
#value ⇒ Object
Returns the value of attribute value
463 464 465 |
# File 'lib/libdevinput.rb', line 463 def value @value end |
Instance Method Details
#code_str ⇒ Object
468 |
# File 'lib/libdevinput.rb', line 468 def code_str; EVENTS[type][code] if EVENTS[type] end |
#time ⇒ Object
466 |
# File 'lib/libdevinput.rb', line 466 def time; Time.at(tv_sec) end |
#to_s ⇒ Object
470 471 472 473 474 475 476 477 478 |
# File 'lib/libdevinput.rb', line 470 def to_s type_s = type.to_s type_s += " (#{type_str})" if type_str code_s = code.to_s code_s += " (#{code_str})" if code_str value_s = value.to_s value_s += " (#{value_str})" if value_str "#{time.iso8601} type: #{type_s} code: #{code_s} value: #{value_s}" end |
#type_str ⇒ Object
467 |
# File 'lib/libdevinput.rb', line 467 def type_str; TYPES[type] end |
#value_str ⇒ Object
469 |
# File 'lib/libdevinput.rb', line 469 def value_str; KEY_VALUES[value] if type == 1 end |