Sha256: d328cc5dd9232c8ce382ab33b78824e0e80b7b9e97ec24cf053f9fc8571807c2

Contents?: true

Size: 705 Bytes

Versions: 3

Compression:

Stored size: 705 Bytes

Contents

module ProconBypassMan::Procon::PushedButtonHelper
  module Static
    def pressed_button?(button)
      binary[
        ::ProconBypassMan::Procon::ButtonCollection.load(button).byte_position
      ].unpack("H*").first.to_i(16).to_s(2).reverse[
        ::ProconBypassMan::Procon::ButtonCollection.load(button).bit_position
      ] == '1'
    end
  end

  module Dynamic
    @@compiled = false
    def compile_if_not_compile_yet!
      unless @@compiled
        ::ProconBypassMan::Procon::ButtonCollection::BUTTONS_MAP.each do |button, _value|
          define_method "pressed_#{button}?" do
            pressed_button?(button)
          end
        end
      end
      @@compiled = true
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
procon_bypass_man-0.1.8 lib/procon_bypass_man/procon/pressed_button_helper.rb
procon_bypass_man-0.1.7 lib/procon_bypass_man/procon/pressed_button_helper.rb
procon_bypass_man-0.1.6 lib/procon_bypass_man/procon/pressed_button_helper.rb