A bit more cleanup of self
This commit is contained in:
parent
f8eb77c959
commit
10bccd896d
|
@ -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...)
|
||||
|
|
|
@ -9,9 +9,8 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = class Driver
|
||||
self = this
|
||||
|
||||
constructor: (opts) ->
|
||||
@self = this
|
||||
@name = opts.name
|
||||
|
||||
start: ->
|
||||
|
|
|
@ -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}'..."
|
||||
|
|
|
@ -9,9 +9,8 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = class Port
|
||||
self = this
|
||||
|
||||
constructor: (data) ->
|
||||
@self = this
|
||||
@isTcp = @isSerial = @isPortless = false
|
||||
@parse(data)
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Reference in New Issue