Class: ProconBypassMan::DeviceConnection::ProconColor

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(color_name) ⇒ void

Parameters:

  • color_name (Symbol)


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

#nameObject

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_positionRange

Returns:

  • (Range)


29
30
31
# File 'lib/procon_bypass_man/device_connection/procon_color.rb', line 29

def byte_position
  BYTE_POSITION
end

#to_bytesString

Returns:

  • (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

Returns:

  • (Boolean)


34
35
36
# File 'lib/procon_bypass_man/device_connection/procon_color.rb', line 34

def valid?
  !!COLOR_TABLE[self.name]
end