Skip to content

Commit

Permalink
Add convenience functions
Browse files Browse the repository at this point in the history
  • Loading branch information
zankich committed Jul 8, 2014
1 parent 3f3444f commit ba63c57
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gobot.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ func (g *Gobot) Robots() *robots {
return g.robots
}

func (g *Gobot) AddRobot(r *Robot) *Robot {
return g.Robots().Add(r)
}

func (g *Gobot) Robot(name string) *Robot {
for _, robot := range g.Robots().robots {
if robot.Name == name {
Expand Down
8 changes: 8 additions & 0 deletions robot.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ func (r *Robot) Devices() *devices {
return r.devices
}

func (r *Robot) AddDevice(d Device) Device {
return r.Devices().Add(d)
}

func (r *Robot) Device(name string) Device {
if r == nil {
return nil
Expand All @@ -129,6 +133,10 @@ func (r *Robot) Connections() *connections {
return r.connections
}

func (r *Robot) AddConnection(c Connection) Connection {
return r.Connections().Add(c)
}

func (r *Robot) Connection(name string) Connection {
if r == nil {
return nil
Expand Down

0 comments on commit ba63c57

Please sign in to comment.