Class: SimpleRaspberryPi
- Inherits:
-
Object
- Object
- SimpleRaspberryPi
- Defined in:
- lib/simple_raspberrypi.rb
Defined Under Namespace
Classes: Void
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.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/simple_raspberrypi.rb', line 21 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" Void.new else self.at(i) end end end |
Class Method Details
Instance Method Details
#pin ⇒ Object
48 |
# File 'lib/simple_raspberrypi.rb', line 48 def pin() @pins.first end |
#pins ⇒ Object
49 |
# File 'lib/simple_raspberrypi.rb', line 49 def pins() @pins end |