Class: ProconBypassMan::PressButtonAware

Inherits:
Object
  • Object
show all
Defined in:
lib/procon_bypass_man/procon/press_button_aware.rb

Constant Summary collapse

BIT_ON =
'1'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(binary) ⇒ PressButtonAware

Returns a new instance of PressButtonAware.



4
5
6
# File 'lib/procon_bypass_man/procon/press_button_aware.rb', line 4

def initialize(binary)
  @binary = binary
end

Instance Method Details

#pressing_button?(button) ⇒ Boolean

Parameters:

  • (Symbol)

Returns:

  • (Boolean)


10
11
12
13
14
# File 'lib/procon_bypass_man/procon/press_button_aware.rb', line 10

def pressing_button?(button)
  button_obj = ProconBypassMan::Procon::Button.new(button)
  byte = @binary[button_obj.byte_position].unpack("C").first.to_s(2).reverse
  byte[button_obj.bit_position] == BIT_ON
end