Class: Revdev::InputId
- Inherits:
-
Object
- Object
- Revdev::InputId
- Includes:
- EachValuesEqual
- Defined in:
- lib/revdev/input_id.rb,
lib/revdev.rb
Overview
wraper of “struct input_id” on “input.h”
Instance Attribute Summary collapse
-
#bustype ⇒ Object
Returns the value of attribute bustype.
-
#product ⇒ Object
Returns the value of attribute product.
-
#vendor ⇒ Object
Returns the value of attribute vendor.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #hr_bustype ⇒ Object
- #hr_version ⇒ Object
-
#initialize(arg = nil, vendor = nil, product = nil, version = nil) ⇒ InputId
constructor
A new instance of InputId.
Methods included from EachValuesEqual
Constructor Details
#initialize(arg = nil, vendor = nil, product = nil, version = nil) ⇒ InputId
Returns a new instance of InputId.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/revdev/input_id.rb', line 10 def initialize(arg=nil, vendor=nil, product=nil, version=nil) if arg.kind_of? String raw_initialize arg elsif arg.kind_of? Hash [:bustype, :vendor, :product, :version].each do |iv| instance_variable_set("@#{iv}", arg[iv] || arg[iv.to_s]) end elsif not ( arg.nil? or vendor.nil? or product.nil? or version.nil? ) @bustype = arg @vendor = vendor @product = product @version = version else raise ArgumentError, "expected a Hash" end end |
Instance Attribute Details
#bustype ⇒ Object
Returns the value of attribute bustype.
8 9 10 |
# File 'lib/revdev/input_id.rb', line 8 def bustype @bustype end |
#product ⇒ Object
Returns the value of attribute product.
8 9 10 |
# File 'lib/revdev/input_id.rb', line 8 def product @product end |
#vendor ⇒ Object
Returns the value of attribute vendor.
8 9 10 |
# File 'lib/revdev/input_id.rb', line 8 def vendor @vendor end |
#version ⇒ Object
Returns the value of attribute version.
8 9 10 |
# File 'lib/revdev/input_id.rb', line 8 def version @version end |
Instance Method Details
#hr_bustype ⇒ Object
27 28 29 |
# File 'lib/revdev/input_id.rb', line 27 def hr_bustype REVERSE_MAPS[:BUS][@bustype] end |
#hr_version ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/revdev/input_id.rb', line 31 def hr_version v = @version v_arr = [] v_arr << (v & 0xff) 2.times do v = (v >> 8) v_arr << (v & 0xff) end v_arr.reverse.join '.' end |