Rubocop autocorrections

This commit is contained in:
Bertocq
2017-11-13 02:22:00 +01:00
parent 57f8aacdd7
commit cd66ba5d54
9 changed files with 63 additions and 65 deletions

View File

@@ -7,11 +7,11 @@ class Poll
def generate
stats = %w[total_participants total_participants_web total_web_valid total_web_white total_web_null
total_participants_booth total_booth_valid total_booth_white total_booth_null
total_valid_votes total_white_votes total_null_votes valid_percentage_web valid_percentage_booth
total_valid_percentage white_percentage_web white_percentage_booth total_white_percentage
null_percentage_web null_percentage_booth total_null_percentage total_participants_web_percentage
total_participants_booth_percentage]
total_participants_booth total_booth_valid total_booth_white total_booth_null
total_valid_votes total_white_votes total_null_votes valid_percentage_web valid_percentage_booth
total_valid_percentage white_percentage_web white_percentage_booth total_white_percentage
null_percentage_web null_percentage_booth total_null_percentage total_participants_web_percentage
total_participants_booth_percentage]
stats.map { |stat_name| [stat_name.to_sym, send(stat_name)] }.to_h
end
@@ -26,9 +26,9 @@ class Poll
end
def total_participants_web_percentage
stats_cache('total_participants_web_percentage') {
(total_participants) == 0 ? 0 : total_participants_web * 100 / total_participants
}
stats_cache('total_participants_web_percentage') do
total_participants == 0 ? 0 : total_participants_web * 100 / total_participants
end
end
def total_participants_booth
@@ -36,9 +36,9 @@ class Poll
end
def total_participants_booth_percentage
stats_cache('total_participants_booth_percentage') {
(total_participants) == 0 ? 0 : total_participants_booth * 100 / total_participants.to_f
}
stats_cache('total_participants_booth_percentage') do
total_participants == 0 ? 0 : total_participants_booth * 100 / total_participants.to_f
end
end
def total_web_valid
@@ -46,9 +46,9 @@ class Poll
end
def valid_percentage_web
stats_cache('valid_percentage_web') {
(total_valid_votes) == 0 ? 0 : total_web_valid * 100 / total_valid_votes.to_f
}
stats_cache('valid_percentage_web') do
total_valid_votes == 0 ? 0 : total_web_valid * 100 / total_valid_votes.to_f
end
end
def total_web_white
@@ -72,9 +72,9 @@ class Poll
end
def valid_percentage_booth
stats_cache('valid_percentage_booth') {
(total_valid_votes) == 0 ? 0 : total_booth_valid * 100 / total_valid_votes.to_f
}
stats_cache('valid_percentage_booth') do
total_valid_votes == 0 ? 0 : total_booth_valid * 100 / total_valid_votes.to_f
end
end
def total_booth_white
@@ -82,9 +82,9 @@ class Poll
end
def white_percentage_booth
stats_cache('white_percentage_booth') {
(total_white_votes) == 0 ? 0 : total_booth_white * 100 / total_white_votes.to_f
}
stats_cache('white_percentage_booth') do
total_white_votes == 0 ? 0 : total_booth_white * 100 / total_white_votes.to_f
end
end
def total_booth_null
@@ -92,9 +92,9 @@ class Poll
end
def null_percentage_booth
stats_cache('null_percentage_booth') {
(total_null_votes == 0) ? 0 : total_booth_null * 100 / total_null_votes.to_f
}
stats_cache('null_percentage_booth') do
total_null_votes == 0 ? 0 : total_booth_null * 100 / total_null_votes.to_f
end
end
def total_valid_votes
@@ -102,9 +102,9 @@ class Poll
end
def total_valid_percentage
stats_cache('total_valid_percentage'){
(total_participants) == 0 ? 0 : total_valid_votes * 100 / total_participants.to_f
}
stats_cache('total_valid_percentage') do
total_participants == 0 ? 0 : total_valid_votes * 100 / total_participants.to_f
end
end
def total_white_votes
@@ -112,9 +112,9 @@ class Poll
end
def total_white_percentage
stats_cache('total_white_percentage') {
(total_participants) == 0 ? 0 : total_white_votes * 100 / total_participants.to_f
}
stats_cache('total_white_percentage') do
total_participants == 0 ? 0 : total_white_votes * 100 / total_participants.to_f
end
end
def total_null_votes
@@ -122,9 +122,9 @@ class Poll
end
def total_null_percentage
stats_cache('total_null_percentage') {
(total_participants) == 0 ? 0 : total_null_votes * 100 / total_participants.to_f
}
stats_cache('total_null_percentage') do
total_participants == 0 ? 0 : total_null_votes * 100 / total_participants.to_f
end
end
def voters