Sha256: 3f497e7b5d7095d0e7e3d869bf1fe60525b3a3e5f047c1391450383c4d925821

Contents?: true

Size: 383 Bytes

Versions: 29

Compression:

Stored size: 383 Bytes

Contents

class ProconBypassMan::PressButtonAware
  BIT_ON = '1'.freeze

  def initialize(binary)
    @binary = binary
  end

  # @param [Symbol]
  # @return [Boolean]
  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
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
procon_bypass_man-0.1.22 lib/procon_bypass_man/procon/press_button_aware.rb
procon_bypass_man-0.1.21 lib/procon_bypass_man/procon/press_button_aware.rb
procon_bypass_man-0.1.20.2 lib/procon_bypass_man/procon/press_button_aware.rb
procon_bypass_man-0.1.20.1 lib/procon_bypass_man/procon/press_button_aware.rb
procon_bypass_man-0.1.20 lib/procon_bypass_man/procon/press_button_aware.rb
procon_bypass_man-0.1.19.1 lib/procon_bypass_man/procon/press_button_aware.rb
procon_bypass_man-0.1.19 lib/procon_bypass_man/procon/press_button_aware.rb
procon_bypass_man-0.1.18 lib/procon_bypass_man/procon/press_button_aware.rb
procon_bypass_man-0.1.17 lib/procon_bypass_man/procon/press_button_aware.rb