Class: ProconBypassMan::DeviceConnection::ProconColor
- Inherits:
-
Object
- Object
- ProconBypassMan::DeviceConnection::ProconColor
- Defined in:
- lib/procon_bypass_man/device_connection/procon_color.rb
Constant Summary collapse
- COLOR_TABLE =
NOTE: [Body, Buttons, Left Grip, Right Grip] RGB
{ red: ['ff 00 00', 'ff ff ff', 'ff 00 00', 'ff 00 00'], blue: ['00 00 ff', 'ff ff ff', '00 00 ff', '00 00 ff'], yellow: ['ff ff 00', 'ff ff ff', 'ff ff 00', 'ff ff 00'], green: ['00 ff 00', 'ff ff ff', '00 ff 00', '00 ff 00'], pink: ['ff 00 ff', 'ff ff ff', 'ff 00 ff', 'ff 00 ff'], cyan: ['00 ff ff', 'ff ff ff', '00 ff ff', '00 ff ff'], white: ['ff ff ff', '00 00 00', 'ff ff ff', 'ff ff ff'], }
- BYTE_POSITION =
20...(20+(3*4))
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #byte_position ⇒ Range
- #initialize(color_name) ⇒ void constructor
- #to_bytes ⇒ String
- #valid? ⇒ Boolean
Constructor Details
#initialize(color_name) ⇒ void
19 20 21 |
# File 'lib/procon_bypass_man/device_connection/procon_color.rb', line 19 def initialize(color_name) self.name = color_name.to_sym end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
15 16 17 |
# File 'lib/procon_bypass_man/device_connection/procon_color.rb', line 15 def name @name end |
Instance Method Details
#byte_position ⇒ Range
29 30 31 |
# File 'lib/procon_bypass_man/device_connection/procon_color.rb', line 29 def byte_position BYTE_POSITION end |
#to_bytes ⇒ String
24 25 26 |
# File 'lib/procon_bypass_man/device_connection/procon_color.rb', line 24 def to_bytes [COLOR_TABLE[self.name].join.gsub(/[,\s]/, '')].pack('H*') end |
#valid? ⇒ Boolean
34 35 36 |
# File 'lib/procon_bypass_man/device_connection/procon_color.rb', line 34 def valid? !!COLOR_TABLE[self.name] end |