Class: SimpleRaspberryPi
- Inherits:
-
Object
- Object
- SimpleRaspberryPi
- Defined in:
- lib/simple_raspberrypi.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(x = []) ⇒ SimpleRaspberryPi
constructor
A new instance of SimpleRaspberryPi.
- #pin ⇒ Object
- #pins ⇒ Object
Constructor Details
#initialize(x = []) ⇒ SimpleRaspberryPi
Returns a new instance of SimpleRaspberryPi.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/simple_raspberrypi.rb', line 14 def initialize(x=[]) a = case x when Integer [x] when Fixnum [x] when String [x] when Array x end @pins = a.map {|pin| RPiPinOut.new pin } def @pins.[](i) if i.to_i >= self.length then puts "RPi warning: RPiPinOut instance #{i.inspect} not found" PinX::Void.new else self.at(i) end end end |
Class Method Details
.[](i) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/simple_raspberrypi.rb', line 29 def @pins.[](i) if i.to_i >= self.length then puts "RPi warning: RPiPinOut instance #{i.inspect} not found" PinX::Void.new else self.at(i) end end |
Instance Method Details
#pin ⇒ Object
41 |
# File 'lib/simple_raspberrypi.rb', line 41 def pin() @pins.first end |
#pins ⇒ Object
42 |
# File 'lib/simple_raspberrypi.rb', line 42 def pins() @pins end |