Class: GpioSysfs::Pin
- Inherits:
-
Object
- Object
- GpioSysfs::Pin
- Defined in:
- lib/gpio_sysfs/pin.rb
Instance Attribute Summary collapse
-
#pin ⇒ Object
Returns the value of attribute pin.
Instance Method Summary collapse
- #direction ⇒ Object
- #direction=(direction) ⇒ Object
- #export ⇒ Object
- #exported? ⇒ Boolean
-
#initialize(pin) ⇒ Pin
constructor
A new instance of Pin.
- #value ⇒ Object
- #value=(value) ⇒ Object
Constructor Details
#initialize(pin) ⇒ Pin
Returns a new instance of Pin.
7 8 9 |
# File 'lib/gpio_sysfs/pin.rb', line 7 def initialize(pin) @pin = pin end |
Instance Attribute Details
#pin ⇒ Object
Returns the value of attribute pin.
5 6 7 |
# File 'lib/gpio_sysfs/pin.rb', line 5 def pin @pin end |
Instance Method Details
#direction ⇒ Object
21 22 23 24 25 |
# File 'lib/gpio_sysfs/pin.rb', line 21 def direction export File.read(direction_path).chomp end |
#direction=(direction) ⇒ Object
27 28 29 30 31 |
# File 'lib/gpio_sysfs/pin.rb', line 27 def direction=(direction) export File.write(direction_path, direction) end |
#export ⇒ Object
11 12 13 14 15 |
# File 'lib/gpio_sysfs/pin.rb', line 11 def export return if exported? File.write(EXPORT_PATH, pin) end |
#exported? ⇒ Boolean
17 18 19 |
# File 'lib/gpio_sysfs/pin.rb', line 17 def exported? File.exist?(pin_path) end |
#value ⇒ Object
33 34 35 36 37 |
# File 'lib/gpio_sysfs/pin.rb', line 33 def value export File.read(value_path).to_i.positive? end |
#value=(value) ⇒ Object
39 40 41 42 43 |
# File 'lib/gpio_sysfs/pin.rb', line 39 def value=(value) self.direction = "out" File.write(value_path, normalized_value(value)) end |