-
Notifications
You must be signed in to change notification settings - Fork 12
Ruby refresher done #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
end | ||
|
||
# in a hash where the keys and values are all numbers | ||
# add all the keys and all the values together, e.g. | ||
# {1 => 1, 2 => 2} becomes 6 | ||
def add_together_keys_and_values(hash) | ||
hash.flatten.inject{ |sum, ele| sum += ele } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space missing to the left of {.
hash_count[word.length] ||= 0 | ||
hash_count[word.length] += 1 | ||
end | ||
return hash_count |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant return
detected.
end | ||
|
||
# return true if the date is a uk bank holiday for 2014 | ||
# the list of bank holidays is here: | ||
# https://www.gov.uk/bank-holidays | ||
def is_a_2014_bank_holiday?(date) | ||
bank_holidays_2014 = [Time.new(2014, 1, 1), Time.new(2014, 4, 18), Time.new(2014, 1, 21), Time.new(2014, 5, 5), Time.new(2014, 8, 25), Time.new(2014, 12, 25), Time.new(2014, 12, 26)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [184/80]
elsif i == 1 | ||
puts "1 bottle of beer on the wall, 1 bottle of beer.\nTake one down and pass it around, no more bottles of beer on the wall.\n\n" | ||
else | ||
puts "#{i} bottles of beer on the wall, #{i} bottles of beer.\nTake one down and pass it around, #{i - 1} bottles of beer on the wall.\n\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [145/80]
# except 'a', 'and' and 'the' | ||
# *unless* they come at the start of the start of the string, e.g. | ||
# 'the lion the witch and the wardrobe' becomes | ||
# 'The Lion the Witch and the Wardrobe' | ||
def titleize_a_string(string) | ||
string.capitalize.split(' ').each do |ele| | ||
ele.capitalize! unless ['a', 'and', 'the'].index(ele) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use %w
or %W
for an array of words.
"#{i} bottles of beer.\n"\ | ||
"Take one down and pass it around, "\ | ||
"#{i - 1} bottles of beer on the wall.\n\n" | ||
puts string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move puts string
out of the conditional.
end | ||
|
||
# return true if the date is a uk bank holiday for 2014 | ||
# the list of bank holidays is here: | ||
# https://www.gov.uk/bank-holidays | ||
def is_a_2014_bank_holiday?(date) | ||
bank_holidays_2014 = [Time.new(2014, 1, 1), Time.new(2014, 4, 18), | ||
Time.new(2014, 1, 21), Time.new(2014, 5, 5), Time.new(2014, 8, 25), | ||
Time.new(2014, 12, 25), Time.new(2014, 12, 26)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align the elements of an array literal if they span more than one line.
Time.new(2014, 8, 25), | ||
Time.new(2014, 12, 25), | ||
Time.new(2014, 12, 26) | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent the right bracket the same as the start of the line where the left bracket is.
end | ||
|
||
# return true if the date is a uk bank holiday for 2014 | ||
# the list of bank holidays is here: | ||
# https://www.gov.uk/bank-holidays | ||
def is_a_2014_bank_holiday?(date) | ||
bank_holidays_2014 = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary spacing detected.
Operator =
should be surrounded by a single space.
au moins c'est utile à produire du code plus performant... |
No description provided.