Class: ProconBypassMan::ProconReader
- Inherits:
-
Object
- Object
- ProconBypassMan::ProconReader
- Defined in:
- lib/procon_bypass_man/procon/value_objects/procon_reader.rb
Instance Method Summary collapse
-
#initialize(binary:) ⇒ ProconReader
constructor
A new instance of ProconReader.
- #left_analog_stick ⇒ Object
- #left_analog_stick_by_abs ⇒ Object
- #pressing ⇒ Array<Symbol>
- #to_hash ⇒ Object
Constructor Details
#initialize(binary:) ⇒ ProconReader
Returns a new instance of ProconReader.
3 4 5 6 7 |
# File 'lib/procon_bypass_man/procon/value_objects/procon_reader.rb', line 3 def initialize(binary: ) @binary = binary @analog_stick = ProconBypassMan::Procon::AnalogStick.new(binary: binary) freeze end |
Instance Method Details
#left_analog_stick ⇒ Object
19 20 21 |
# File 'lib/procon_bypass_man/procon/value_objects/procon_reader.rb', line 19 def left_analog_stick { x: @analog_stick.relative_x, y: @analog_stick.relative_y } end |
#left_analog_stick_by_abs ⇒ Object
23 24 25 |
# File 'lib/procon_bypass_man/procon/value_objects/procon_reader.rb', line 23 def left_analog_stick_by_abs { x: @analog_stick.abs_x, y: @analog_stick.abs_y } end |
#pressing ⇒ Array<Symbol>
10 11 12 13 14 15 16 17 |
# File 'lib/procon_bypass_man/procon/value_objects/procon_reader.rb', line 10 def pressing aware = ProconBypassMan::PressButtonAware.new(@binary) pressed_table = ::ProconBypassMan::Procon::ButtonCollection::BUTTONS.reduce({}) do |acc, | acc[] = aware.() acc end pressed_table.select { |_key, value| value }.keys end |
#to_hash ⇒ Object
27 28 29 30 31 32 |
# File 'lib/procon_bypass_man/procon/value_objects/procon_reader.rb', line 27 def to_hash { left_analog_stick: left_analog_stick, left_analog_stick_by_abs: left_analog_stick_by_abs, buttons: pressing, } end |