Class: BubBot::Slack::Command::List

Inherits:
BubBot::Slack::Command show all
Includes:
ActionView::Helpers::DateHelper
Defined in:
lib/bub_bot/slack/commands/list.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BubBot::Slack::Command

can_handle?, #initialize

Constructor Details

This class inherits a constructor from BubBot::Slack::Command

Class Method Details

.aliasesObject



7
8
9
# File 'lib/bub_bot/slack/commands/list.rb', line 7

def self.aliases
  %w(list status all wazup)
end

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/bub_bot/slack/commands/list.rb', line 11

def run
  list_strings = servers.list.map do |server, claim|
    if claim['expires_at']
      time_ago = time_ago_in_words(claim['expires_at'])
      "#{server}: *#{claim['user']}'s* for the next #{time_ago}"
    else
      "#{server}: *free*"
    end
  end

  respond(list_strings.join("\n"))
end