class Slacks::Channel
Attributes
id[R]
name[R]
slack[R]
type[R]
Public Class Methods
new(slack, attributes={})
click to toggle source
# File lib/slacks/channel.rb, line 5 def initialize(slack, attributes={}) @slack = slack @id = attributes["id"] @name = attributes["name"] @type = :channel @type = :group if attributes["is_group"] @type = :direct_message if attributes["is_im"] end
Public Instance Methods
==(other)
click to toggle source
# File lib/slacks/channel.rb, line 49 def ==(other) self.class == other.class && self.id == other.id end
direct_message?()
click to toggle source
# File lib/slacks/channel.rb, line 29 def direct_message? type == :direct_message end
guest?()
click to toggle source
# File lib/slacks/channel.rb, line 41 def guest? false end
inspect()
click to toggle source
# File lib/slacks/channel.rb, line 45 def inspect "<Slacks::Channel id=\"#{id}\" name=\"#{name}\">" end
private_group?()
click to toggle source
# File lib/slacks/channel.rb, line 35 def private_group? type == :group end
reply(*messages)
click to toggle source
# File lib/slacks/channel.rb, line 14 def reply(*messages) return unless messages.any? if messages.first.is_a?(Array) reply_many(messages[0]) else reply_one(*messages) end end
Also aliased as: say
to_s()
click to toggle source
# File lib/slacks/channel.rb, line 53 def to_s return name if private? return "@#{name}" if direct_message? "##{name}" end
typing()
click to toggle source
# File lib/slacks/channel.rb, line 25 def typing slack.typing_on(self) end
Protected Instance Methods
reply_many(messages)
click to toggle source
# File lib/slacks/channel.rb, line 65 def reply_many(messages) messages.each_with_index.map do |message, i| sleep message.length / slack.typing_speed if i > 0 slack.send_message(message, channel: id) end end
reply_one(message, options={})
click to toggle source
# File lib/slacks/channel.rb, line 61 def reply_one(message, options={}) slack.send_message(message, options.merge(channel: id)) end