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
54 55 56 |
# File 'lib/slacks/channel.rb', line 54 def ==(other) self.class == other.class && self.id == other.id end |
#direct_message? ⇒ Boolean Also known as: dm?, im?
34 35 36 |
# File 'lib/slacks/channel.rb', line 34 def type == :direct_message end |
#guest? ⇒ Boolean
46 47 48 |
# File 'lib/slacks/channel.rb', line 46 def guest? false end |
#inspect ⇒ Object
50 51 52 |
# File 'lib/slacks/channel.rb', line 50 def inspect "<Slacks::Channel id=\"#{id}\" name=\"#{name}\">" end |
#private_group? ⇒ Boolean Also known as: group?, private?
40 41 42 |
# File 'lib/slacks/channel.rb', line 40 def private_group? type == :group end |
#reply(*messages) ⇒ Object Also known as: say
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/slacks/channel.rb', line 14 def reply(*) .flatten! return unless .any? = .shift = {} = .shift if .length == 1 && [0].is_a?(Hash) slack.(, .merge(channel: id)) .each do || sleep .length / slack.typing_speed slack.(, channel: id) end end |
#to_s ⇒ Object
58 59 60 61 62 |
# File 'lib/slacks/channel.rb', line 58 def to_s return name if private? return "@#{name}" if "##{name}" end |
#typing ⇒ Object
30 31 32 |
# File 'lib/slacks/channel.rb', line 30 def typing slack.typing_on(self) end |