Class: LittleWire::Nunchuck::NunchuckFrame::Buttons

Inherits:
Object
  • Object
show all
Defined in:
lib/littlewire/gadgets/nunchuck.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(c, z) ⇒ Buttons

Returns a new instance of Buttons.



86
87
88
# File 'lib/littlewire/gadgets/nunchuck.rb', line 86

def initialize c,z
  @c,@z = c,z
end

Instance Attribute Details

#cObject

Returns the value of attribute c.



89
90
91
# File 'lib/littlewire/gadgets/nunchuck.rb', line 89

def c
  @c
end

#zObject

Returns the value of attribute z.



89
90
91
# File 'lib/littlewire/gadgets/nunchuck.rb', line 89

def z
  @z
end

Instance Method Details

#down?(button) ⇒ Boolean

is button down?

Returns:

  • (Boolean)


92
93
94
# File 'lib/littlewire/gadgets/nunchuck.rb', line 92

def down? button
  instance_variable_get("@#{button.to_s.downcase}")
end

#inspectObject



100
# File 'lib/littlewire/gadgets/nunchuck.rb', line 100

def inspect; "<Buttons:#{'C' if @c}#{'Z' if @z}>"; end

#up?(button) ⇒ Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/littlewire/gadgets/nunchuck.rb', line 96

def up? button
  not down? button
end