Class: Fusuma::Device
- Inherits:
-
Object
- Object
- Fusuma::Device
- Defined in:
- lib/fusuma/device.rb
Overview
detect input device
Defined Under Namespace
Classes: LineParser
Instance Attribute Summary collapse
-
#available ⇒ Object
Returns the value of attribute available.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id: nil, name: nil, available: nil) ⇒ Device
constructor
A new instance of Device.
Constructor Details
#initialize(id: nil, name: nil, available: nil) ⇒ Device
Returns a new instance of Device.
8 9 10 11 12 |
# File 'lib/fusuma/device.rb', line 8 def initialize(id: nil, name: nil, available: nil) @id = id @name = name @available = available end |
Instance Attribute Details
#available ⇒ Object
Returns the value of attribute available.
6 7 8 |
# File 'lib/fusuma/device.rb', line 6 def available @available end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/fusuma/device.rb', line 4 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/fusuma/device.rb', line 5 def name @name end |
Class Method Details
.available ⇒ Array
27 28 29 30 31 32 33 34 35 |
# File 'lib/fusuma/device.rb', line 27 def available @available ||= fetch_available.tap do |d| MultiLogger.debug(available_devices: d) raise 'Touchpad is not found' if d.empty? end rescue RuntimeError => ex MultiLogger.error(ex.) exit 1 end |
.given_device=(name) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/fusuma/device.rb', line 42 def given_device=(name) return if name.nil? @available = available.select { |d| d.name == name } return unless names.empty? MultiLogger.error("Device #{name} is not found.\n Check available device with: $ fusuma --list-devices\n") exit 1 end |
.ids ⇒ Array
16 17 18 |
# File 'lib/fusuma/device.rb', line 16 def ids available.map(&:id) end |
.names ⇒ Array
21 22 23 |
# File 'lib/fusuma/device.rb', line 21 def names available.map(&:name) end |
.reset ⇒ Object
37 38 39 |
# File 'lib/fusuma/device.rb', line 37 def reset @available = nil end |