Class: SlackbotFrd::SlackMethods::ChannelsList
- Inherits:
-
Object
- Object
- SlackbotFrd::SlackMethods::ChannelsList
- Includes:
- HTTParty
- Defined in:
- lib/slackbot_frd/slack_methods/channels_list.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #connect ⇒ Object
- #ids_to_names ⇒ Object
-
#initialize(token) ⇒ ChannelsList
constructor
A new instance of ChannelsList.
- #names_to_ids ⇒ Object
Constructor Details
#initialize(token) ⇒ ChannelsList
12 13 14 |
# File 'lib/slackbot_frd/slack_methods/channels_list.rb', line 12 def initialize(token) @token = token end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
10 11 12 |
# File 'lib/slackbot_frd/slack_methods/channels_list.rb', line 10 def response @response end |
Instance Method Details
#connect ⇒ Object
16 17 18 19 |
# File 'lib/slackbot_frd/slack_methods/channels_list.rb', line 16 def connect @response = JSON.parse(self.class.post('', :body => { token: @token } ).body) self end |
#ids_to_names ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/slackbot_frd/slack_methods/channels_list.rb', line 21 def ids_to_names retval = {} @response["channels"].each do |channel| retval[channel["id"]] = channel["name"] end retval end |
#names_to_ids ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/slackbot_frd/slack_methods/channels_list.rb', line 29 def names_to_ids retval = {} @response["channels"].each do |channel| retval[channel["name"]] = channel["id"] end retval end |