lib/artoo/adaptors/sphero.rb in artoo-0.4.0 vs lib/artoo/adaptors/sphero.rb in artoo-0.4.1
- old
+ new
@@ -1,21 +1,29 @@
require 'artoo/adaptors/adaptor'
module Artoo
module Adaptors
- # Connect to a Sphero (http://gosphero.com)
+ # Connect to a Sphero device
+ # @see http://gosphero.com Sphero information
+ # @see http://rubydoc.info/gems/hybridgroup-sphero HybridGroup Sphero Documentation
class Sphero < Adaptor
finalizer :finalize
- RETRY_COUNT = 5
attr_reader :sphero
+ # Number of retries when connecting
+ RETRY_COUNT = 5
+
+ # Closes connection with device if connected
+ # @return [Boolean]
def finalize
if connected?
sphero.close
end
end
+ # Creates a connection with Sphero object with retries
+ # @return [Boolean]
def connect
@retries_left = RETRY_COUNT
require 'sphero' unless defined?(::Sphero)
begin
@sphero = ::Sphero.new(connect_to)
@@ -31,16 +39,20 @@
return false
end
end
end
+ # Closes connection with device
+ # @return [Boolean]
def disconnect
sphero.close
super
end
+ # Uses method missing to call sphero actions
+ # @see http://rubydoc.info/gems/hybridgroup-sphero/Sphero Sphero documentation
def method_missing(method_name, *arguments, &block)
sphero.send(method_name, *arguments, &block)
end
end
end
-end
\ No newline at end of file
+end