class Ruboty::PiGpio::Actions::Base

Protected Instance Methods

export() click to toggle source
# File lib/ruboty/pi_gpio/actions/base.rb, line 15
def export
  open('/sys/class/gpio/export', 'w') { |f| f.write(pin) }
rescue => e
  log(e)
end
log(e = nil) click to toggle source
# File lib/ruboty/pi_gpio/actions/base.rb, line 27
def log(e = nil)
  Ruboty.logger.info(message.body)
  unless e.nil?
    Ruboty.logger.error(e.message)
    Ruboty.logger.error(e.backtrace.join("\n") + "\n")
  end
end
pin() click to toggle source
# File lib/ruboty/pi_gpio/actions/base.rb, line 7
def pin
  message[:pin]
end
prefix() click to toggle source
# File lib/ruboty/pi_gpio/actions/base.rb, line 35
def prefix
  Ruboty::Action.prefix_pattern(robot.name)
end
robot() click to toggle source
# File lib/ruboty/pi_gpio/actions/base.rb, line 11
def robot
  message.robot
end
unexport() click to toggle source
# File lib/ruboty/pi_gpio/actions/base.rb, line 21
def unexport
  open('/sys/class/gpio/unexport', 'w') { |f| f.write(pin) }
rescue => e
  log(e)
end