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 : () -> Array.
-
.available ⇒ Array
: () -> Array.
-
.reset ⇒ Object
: () -> nil.
Instance Method Summary collapse
-
#assign_attributes(attributes) ⇒ Object
: (Hash[untyped, untyped]) -> Hash[untyped, untyped].
-
#initialize(id: nil, name: nil, capabilities: nil, available: nil) ⇒ Device
constructor
: (?id: nil | String, ?name: nil | String, ?capabilities: nil, ?available: nil | bool) -> void.
Constructor Details
#initialize(id: nil, name: nil, capabilities: nil, available: nil) ⇒ Device
: (?id: nil | String, ?name: nil | String, ?capabilities: nil, ?available: nil | bool) -> void
12 13 14 15 16 17 |
# File 'lib/fusuma/device.rb', line 12 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 : () -> Array
41 42 43 44 45 |
# File 'lib/fusuma/device.rb', line 41 def all @all ||= fetch_devices.partition do |d| d.capabilities.match?(/gesture/) end.flatten end |
.available ⇒ Array
: () -> Array
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/fusuma/device.rb', line 50 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
: () -> nil
62 63 64 65 |
# File 'lib/fusuma/device.rb', line 62 def reset @all = nil @available = nil end |
Instance Method Details
#assign_attributes(attributes) ⇒ Object
: (Hash[untyped, untyped]) -> Hash[untyped, untyped]
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/fusuma/device.rb', line 21 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 |