A bit more cleanup of self

This commit is contained in:
deadprogram 2013-10-24 00:50:53 -07:00
parent f8eb77c959
commit 10bccd896d
5 changed files with 7 additions and 12 deletions

View File

@ -11,9 +11,8 @@
require('./cylon')
module.exports = class Device
self = this
constructor: (opts = {}) ->
@self = this
@robot = opts.robot
@name = opts.name
@connection = @determineConnection(opts.connection) or @defaultConnection()
@ -34,10 +33,10 @@ module.exports = class Device
requireDriver: (driverName) ->
Logger.info "dynamic load driver"
@robot.requireDriver(driverName, this)
@robot.requireDriver(driverName, @self)
addCommands: (object) ->
@addProxy(object, method) for method in object.commands()
addProxy: (object, method) ->
this[method] = (args...) -> object[method](args...)
@self[method] = (args...) -> object[method](args...)

View File

@ -9,9 +9,8 @@
'use strict';
module.exports = class Driver
self = this
constructor: (opts) ->
@self = this
@name = opts.name
start: ->

View File

@ -13,14 +13,13 @@ module.exports =
new Loopback(opts)
class Loopback
self = this
constructor: (opts) ->
@self = this
@name = opts.name
connect: ->
Logger.info "Connecting to adaptor '#{@name}'..."
self
@self
disconnect: ->
Logger.info "Disconnecting from adaptor '#{@name}'..."

View File

@ -9,9 +9,8 @@
'use strict';
module.exports = class Port
self = this
constructor: (data) ->
@self = this
@isTcp = @isSerial = @isPortless = false
@parse(data)

View File

@ -6,5 +6,4 @@ describe "Driver", ->
driver = new Driver(name: "driving")
it "should have a name", ->
driver.should.have.keys 'name'
driver.name.should.be.equal 'driving'