Conversation
slack.rbWhat We're Looking For
|
| puts "No details to show, please select a channel or user." | ||
| else | ||
| if user.nil? | ||
| recipient.details(channel["id"]) |
There was a problem hiding this comment.
Your recipient class doesn't have an instance method called details. You made a class method instead.
| require 'awesome_print' | ||
| require 'dotenv' | ||
| Dotenv.load | ||
|
|
There was a problem hiding this comment.
Your Channel class here is just a collection of class methods. It would be better if you had a class to represent a channel with instance variables etc. The get_channels method could then return an array of channel instances. That would also allow you to have an instance method to send messages, or get details.
|
|
||
| def self.list_channels(channels) | ||
| channels.each do |channel| | ||
| puts "Channel name: #{channel["name"]}" |
There was a problem hiding this comment.
You are also mixing the presentation parts of the program with your business logic. It's advisable to put the parts that deal with data and application logic separate from code that presents an interface to the user.
| @is_user = is_user | ||
| end | ||
|
|
||
| def self.details(slack_id) |
There was a problem hiding this comment.
This method would make more sense as an instance method where you could get the details of that specific instance of Recipient.
| require "dotenv" | ||
| Dotenv.load | ||
|
|
||
| class Recipient |
There was a problem hiding this comment.
You'll notice the code for this class is pretty repetitive. That's a clear sign that you can refactor this method to simplify the logic a bit.
Check out the instructor reference design and ask me questions if you have them.
| puts "f. send message" | ||
| puts "g. quit\n\n" | ||
|
|
||
| ap "What would you like to do?" |
There was a problem hiding this comment.
BTW thank you for letting me select a letter for an option rather than typing out the entire "list users" etc.
| require 'dotenv' | ||
| Dotenv.load | ||
|
|
||
| class User |
There was a problem hiding this comment.
This class has a lot of the same issues Channel has.
slack.rb
Congratulations! You're submitting your assignment!
You and your partner should collaborate on the answers to these questions.
Comprehension Questions