Class: Webrelais::Pin
- Inherits:
-
Object
- Object
- Webrelais::Pin
- Defined in:
- lib/webrelais/pin.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
-
#initialize(id) ⇒ Pin
constructor
A new instance of Pin.
- #to_s ⇒ Object
- #value ⇒ Object
- #value=(v) ⇒ Object
Constructor Details
#initialize(id) ⇒ Pin
Returns a new instance of Pin.
5 6 7 |
# File 'lib/webrelais/pin.rb', line 5 def initialize(id) @id = id end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/webrelais/pin.rb', line 3 def id @id end |
Instance Method Details
#to_s ⇒ Object
19 20 21 |
# File 'lib/webrelais/pin.rb', line 19 def to_s "Pin #{id}" end |
#value ⇒ Object
9 10 11 12 13 |
# File 'lib/webrelais/pin.rb', line 9 def value %x[#{Webrelais.gpio} read #{id}].chomp.to_i ^ 1 rescue -1 end |
#value=(v) ⇒ Object
15 16 17 |
# File 'lib/webrelais/pin.rb', line 15 def value=(v) %x[#{Webrelais.gpio} write #{id} #{v ^ 1}] rescue -1 end |