Class: PiDriver::Pin::FileHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/pi_driver/pin/file_helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(gpio_number) ⇒ FileHelper

Returns a new instance of FileHelper.



6
7
8
9
# File 'lib/pi_driver/pin/file_helper.rb', line 6

def initialize(gpio_number)
  @gpio_number = gpio_number
  @directory_helper = DirectoryHelper.new @gpio_number
end

Instance Method Details

#read_valueObject



11
12
13
# File 'lib/pi_driver/pin/file_helper.rb', line 11

def read_value
  File.read(@directory_helper.value).to_i
end

#write_direction(direction) ⇒ Object



15
16
17
# File 'lib/pi_driver/pin/file_helper.rb', line 15

def write_direction(direction)
  File.write(@directory_helper.direction, direction)
end

#write_exportObject



19
20
21
# File 'lib/pi_driver/pin/file_helper.rb', line 19

def write_export
  File.write(@directory_helper.export, @gpio_number)
end

#write_value(value) ⇒ Object



23
24
25
# File 'lib/pi_driver/pin/file_helper.rb', line 23

def write_value(value)
  File.write(@directory_helper.value, value)
end