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
readonly
Returns the value of attribute available.
-
#capabilities ⇒ Object
readonly
Returns the value of attribute capabilities.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
-
.all ⇒ Array
Return devices sort devices by capabilities of gesture.
- .available ⇒ Array
- .reset ⇒ Object
Instance Method Summary collapse
- #assign_attributes(attributes) ⇒ Object
-
#initialize(id: nil, name: nil, capabilities: nil, available: nil) ⇒ Device
constructor
A new instance of Device.
Constructor Details
#initialize(id: nil, name: nil, capabilities: nil, available: nil) ⇒ Device
Returns a new instance of Device.
11 12 13 14 15 16 |
# File 'lib/fusuma/device.rb', line 11 def initialize(id: nil, name: nil, capabilities: nil, available: nil) @id = id @name = name @capabilities = capabilities @available = available end |
Instance Attribute Details
#available ⇒ Object (readonly)
Returns the value of attribute available.
9 10 11 |
# File 'lib/fusuma/device.rb', line 9 def available @available end |
#capabilities ⇒ Object (readonly)
Returns the value of attribute capabilities.
9 10 11 |
# File 'lib/fusuma/device.rb', line 9 def capabilities @capabilities end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/fusuma/device.rb', line 9 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/fusuma/device.rb', line 9 def name @name end |
Class Method Details
.all ⇒ Array
Return devices sort devices by capabilities of gesture
38 39 40 41 42 |
# File 'lib/fusuma/device.rb', line 38 def all @all ||= fetch_devices.partition do |d| d.capabilities.match?(/gesture/) end.flatten end |
.available ⇒ Array
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/fusuma/device.rb', line 46 def available @available ||= all.select(&:available).tap do |d| MultiLogger.debug(available_devices: d) raise "Touchpad is not found" if d.empty? end rescue RuntimeError => e # FIXME: should not exit without Runner class MultiLogger.error(e.) exit 1 end |
.reset ⇒ Object
57 58 59 60 |
# File 'lib/fusuma/device.rb', line 57 def reset @all = nil @available = nil end |
Instance Method Details
#assign_attributes(attributes) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fusuma/device.rb', line 19 def assign_attributes(attributes) attributes.each do |k, v| case k when :id @id = v when :name @name = v when :capabilities @capabilities = v when :available @available = v end end end |