Skip to content

Commit

Permalink
Update to use for x in y instead of forEach
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Bell committed Oct 26, 2011
1 parent 6780d7a commit df4912b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
5 changes: 2 additions & 3 deletions src/hubot/campfire.coffee
Expand Up @@ -4,14 +4,13 @@ EventEmitter = require("events").EventEmitter

class Campfire extends Robot
send: (user, strings...) ->
strings.forEach (str) =>
for str in strings
@bot.Room(user.room).speak str, (err, data) ->
if err
console.log "campfire error: #{err}"

reply: (user, strings...) ->
strings.forEach (str) =>
@send user, "#{user.name}: #{str}"
@send user, "#{user.name}: #{str}" for str in strings

run: ->
self = @
Expand Down
4 changes: 2 additions & 2 deletions src/hubot/irc.coffee
Expand Up @@ -3,12 +3,12 @@ Irc = require "irc"

class IrcBot extends Robot
send: (user, strings...) ->
strings.forEach (str) =>
for str in strings
console.log "#{user.name}: #{str}"
@bot.say(user.room, str)

reply: (user, strings...) ->
strings.forEach (str) =>
for str in strings
@send user, "#{user.name}: #{str}"

run: ->
Expand Down
2 changes: 1 addition & 1 deletion src/hubot/scripts/roles.coffee
Expand Up @@ -38,7 +38,7 @@ module.exports = (robot) ->
msg.send "I know"
else
user.roles.push(newRole)
if name.toLowerCase() == robot.name
if name.toLowerCase() is robot.name
msg.send "Ok, I am #{newRole}."
else
msg.send "Ok, #{name} is #{newRole}."
Expand Down
4 changes: 2 additions & 2 deletions src/hubot/shell.coffee
Expand Up @@ -2,11 +2,11 @@ Robot = require 'robot'

class Shell extends Robot
send: (user, strings...) ->
strings.forEach (str) ->
for str in strings
console.log str

reply: (user, strings...) ->
strings.forEach (str) =>
for str in strings
@send user, "#{user.name}: #{str}"

run: ->
Expand Down
4 changes: 2 additions & 2 deletions src/robot.coffee
Expand Up @@ -59,7 +59,7 @@ class Robot
#
# Returns nothing.
receive: (message) ->
@listeners.forEach (lst) -> lst.call message
listener.call message for listener in @listeners

# Public: Loads every script in the given path.
#
Expand All @@ -70,7 +70,7 @@ class Robot
Path.exists path, (exists) =>
if exists
@loadPaths.push path
Fs.readdirSync(path).forEach (file) =>
for file in Fs.readdirSync(path)
@loadFile path, file

# Public: Loads a file in path
Expand Down

0 comments on commit df4912b

Please sign in to comment.