Work and create new robot
This commit is contained in:
parent
b0f4d9f12b
commit
c9953b8830
|
@ -24,7 +24,7 @@ var robot = cylon.robot({
|
|||
});
|
||||
|
||||
// start working
|
||||
robot.work();
|
||||
robot.start();
|
||||
```
|
||||
|
||||
```coffee-script
|
||||
|
@ -42,8 +42,7 @@ robot = cylon.robot
|
|||
every 1.second, ->
|
||||
led.toggle
|
||||
|
||||
# start working
|
||||
robot.work
|
||||
robot.start
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
|
|
@ -11,3 +11,4 @@
|
|||
module.exports = class Connection
|
||||
constructor: (opts) ->
|
||||
@name = opts.name
|
||||
@adaptor = opts.adaptor
|
||||
|
|
|
@ -8,5 +8,7 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
exports.robot = ->
|
||||
'irobot'
|
||||
Robot = source("robot")
|
||||
|
||||
exports.robot = (opts) ->
|
||||
new Robot(opts)
|
||||
|
|
|
@ -11,3 +11,4 @@
|
|||
module.exports = class Device
|
||||
constructor: (opts) ->
|
||||
@name = opts.name
|
||||
@driver = opts.driver
|
||||
|
|
|
@ -11,3 +11,7 @@
|
|||
module.exports = class Robot
|
||||
constructor: (opts) ->
|
||||
@name = opts.name
|
||||
@work = opts.work or -> (console.log "No work yet")
|
||||
|
||||
start: ->
|
||||
(@work)
|
||||
|
|
|
@ -3,8 +3,10 @@
|
|||
Connection = source("connection")
|
||||
|
||||
describe "basic tests", ->
|
||||
r = new Connection(name: "connective")
|
||||
r = new Connection(name: "connective", adaptor: "adaptive")
|
||||
|
||||
it "connection should have a name", ->
|
||||
r.should.have.keys 'name'
|
||||
r.name.should.be.equal 'connective'
|
||||
|
||||
it "connection should have an adaptor", ->
|
||||
r.adaptor.should.be.equal 'adaptive'
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
cylon = source("cylon")
|
||||
Robot = source("robot")
|
||||
|
||||
describe "basic tests", ->
|
||||
it "standard async test", (done) ->
|
||||
|
@ -32,5 +33,5 @@ describe "basic tests", ->
|
|||
# Now on to a `real` test
|
||||
it "cylon should create a robot", ->
|
||||
cylon.should.have.keys 'robot'
|
||||
cylon.robot.should.be.a 'function'
|
||||
cylon.robot().should.be.equal 'irobot'
|
||||
robot = cylon.robot(name: 'caprica')
|
||||
robot.name.should.be.eql 'caprica'
|
||||
|
|
|
@ -3,8 +3,10 @@
|
|||
Device = source("device")
|
||||
|
||||
describe "basic tests", ->
|
||||
r = new Device(name: "devisive")
|
||||
r = new Device(name: "devisive", driver: 'driving')
|
||||
|
||||
it "device should have a name", ->
|
||||
r.should.have.keys 'name'
|
||||
r.name.should.be.equal 'devisive'
|
||||
|
||||
it "device should have an driver", ->
|
||||
r.driver.should.be.equal 'driving'
|
||||
|
|
|
@ -3,8 +3,13 @@
|
|||
Robot = source("robot")
|
||||
|
||||
describe "basic tests", ->
|
||||
r = new Robot(name: "irobot")
|
||||
testWork = ->
|
||||
console.log "hi"
|
||||
|
||||
r = new Robot(name: "irobot", work: testWork)
|
||||
|
||||
it "robot should have a name", ->
|
||||
r.should.have.keys 'name'
|
||||
r.name.should.be.equal 'irobot'
|
||||
|
||||
it "robot should have work", ->
|
||||
r.work.should.be.equal testWork
|
||||
|
|
Loading…
Reference in New Issue