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.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #assign_attributes(attributes) ⇒ Object
-
#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.
10 11 12 13 14 |
# File 'lib/fusuma/device.rb', line 10 def initialize(id: nil, name: nil, available: nil) @id = id @name = name @available = available end |
Instance Attribute Details
#available ⇒ Object (readonly)
Returns the value of attribute available.
6 7 8 |
# File 'lib/fusuma/device.rb', line 6 def available @available end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/fusuma/device.rb', line 8 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/fusuma/device.rb', line 7 def name @name end |
Class Method Details
.all ⇒ Array
32 33 34 |
# File 'lib/fusuma/device.rb', line 32 def all @all ||= fetch_devices end |
.available ⇒ Array
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fusuma/device.rb', line 38 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
49 50 51 52 |
# File 'lib/fusuma/device.rb', line 49 def reset @all = nil @available = nil end |
Instance Method Details
#assign_attributes(attributes) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/fusuma/device.rb', line 17 def assign_attributes(attributes) attributes.each do |k, v| case k when :id @id = v when :name @name = v when :available @available = v end end end |