Class: Slacks::Channel
- Inherits:
-
Object
- Object
- Slacks::Channel
- Defined in:
- lib/slacks/channel.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #direct_message? ⇒ Boolean (also: #dm?, #im?)
- #guest? ⇒ Boolean
-
#initialize(slack, attributes = {}) ⇒ Channel
constructor
A new instance of Channel.
- #inspect ⇒ Object
- #private_group? ⇒ Boolean (also: #group?, #private?)
- #reply(*messages) ⇒ Object (also: #say)
- #to_s ⇒ Object
- #typing ⇒ Object
Constructor Details
#initialize(slack, attributes = {}) ⇒ Channel
Returns a new instance of Channel.
5 6 7 8 9 10 11 12 |
# 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 |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/slacks/channel.rb', line 3 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/slacks/channel.rb', line 3 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/slacks/channel.rb', line 3 def type @type end |
Instance Method Details
#==(other) ⇒ Object
49 50 51 |
# File 'lib/slacks/channel.rb', line 49 def ==(other) self.class == other.class && self.id == other.id end |
#direct_message? ⇒ Boolean Also known as: dm?, im?
29 30 31 |
# File 'lib/slacks/channel.rb', line 29 def type == :direct_message end |
#guest? ⇒ Boolean
41 42 43 |
# File 'lib/slacks/channel.rb', line 41 def guest? false end |
#inspect ⇒ Object
45 46 47 |
# File 'lib/slacks/channel.rb', line 45 def inspect "<Slacks::Channel id=\"#{id}\" name=\"#{name}\">" end |
#private_group? ⇒ Boolean Also known as: group?, private?
35 36 37 |
# File 'lib/slacks/channel.rb', line 35 def private_group? type == :group end |
#reply(*messages) ⇒ Object Also known as: say
14 15 16 17 18 19 20 21 22 |
# File 'lib/slacks/channel.rb', line 14 def reply(*) return unless .any? if .first.is_a?(Array) reply_many([0]) else reply_one(*) end end |
#to_s ⇒ Object
53 54 55 56 57 |
# File 'lib/slacks/channel.rb', line 53 def to_s return name if private? return "@#{name}" if "##{name}" end |
#typing ⇒ Object
25 26 27 |
# File 'lib/slacks/channel.rb', line 25 def typing slack.typing_on(self) end |