New answers tagged

0

For one of my project, I have used this kind of logging Hoping this would help you $FILE_LOG = Logging.create_log(File.expand_path('LoggingFile.log'), Logger::DEBUG) module Logging def self.create_log(output_location level) log = Logger.new(output_location, 'weekly').tap do |l| next unless l l.level = level l.progname = File....


2

Don't think your question belongs to this code review section. You would have gotten help much faster if had posted in stackoverflow instead. Anyway there are couple points you need to check. The CreateComments migration must have been updated (or at least there was another migration that changed the table) because the migration does not say anything about ...


0

These things are very much a matter of preference but I would go for something like: mails = [ @note.cc_emails, @note.to_emails ].compact.join('') which tends to remain usable as you add more clauses


2

I am not a professional game developer, just trying to help you base on my experience with Ruby so far. Glad to see your willingness of coding correctly from the beginning. Some points to improve: 1.Move the bot names and game mode options to CONSTANTS 2.Prompting for user's input is duplicated many times, you should make a function that take prompting ...


3

The biggest thing that will allow the code to clean up a fair bit is if you had made a subclass of Player for AIPlayer: class AIPlayer < Player NAMES = ['Bob', 'Joseph', 'Catherine', 'Paul', 'Tom', 'Baker'] def initialize super NAMES.sample end end that will allow you to add a method get_weapon to Player, which would ask for the user input ...


1

I doubt if all those logic is meant to be in the ApplicationHelper. You could create a new helper file and move that logic. As you have three constant values declared within the method body, you can move them outside as constants, and modify the value of total_stars depending on the conditions you have: ZERO_STAR_ICON_NAME = "star" FULL_STAR_ICON_NAME = "...


5

You can make use of the Array.new, passing in the maximum number of stars you want to show, and defaulting all the stars to empty. Then, you can fill in the number of full stars you need. Then, finally, thanks to Numeric's divmod returning either 0 or 1 for the number of half stars you need, you make one more pass and fill in the number of half stars you ...


Top 50 recent answers are included