Created
August 3, 2016 15:33
-
-
Save fee1good/eb9af45271aa634507928dd1a0f7055a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# file_name = '/Users/VictorK/ROR2/movies.txt' — используется при установке дефолтного значения | |
time_film = ARGV[1].to_s #используется при вводе аргументов из консоли | |
file_name = ARGV[0].to_s | |
if ARGV.empty? | |
# ARGV[0] = file_name — используется при установке дефолтного значения | |
puts 'Вы не ввели название файла, повторите попытку:' | |
file_name = gets.chomp | |
if file_name != 'movies.txt' | |
puts 'Данного файла не существует' | |
abort | |
end | |
puts 'Ввведите название фильма:' | |
time_film = gets.chomp | |
end | |
ratio = ['*', '**','***', '****', '*****', '******', '*******', '********', '*********',] | |
File.readlines(file_name).each do |line| | |
film_element = line.split('|') | |
if film_element[1].include?(time_film) | |
print film_element[1] + ' Rank:' | |
if film_element[7].split('8.').include?('1') | |
puts ratio[0] | |
end | |
if film_element[7].split('8.').include?('2') | |
puts ratio[1] | |
end | |
if film_element[7].split('8.').include?('3') | |
puts ratio[2] | |
end | |
if film_element[7].split('8.').include?('4') | |
puts ratio[3] | |
end | |
if film_element[7].split('8.').include?('5') | |
puts ratio[4] | |
end | |
if film_element[7].split('8.').include?('6') | |
puts ratio[5] | |
end | |
if film_element[7].split('8.').include?('7') | |
puts ratio[6] | |
end | |
if film_element[7].split('8.').include?('8') | |
puts ratio[7] | |
end | |
if film_element[7].split('8.').include?('9') | |
puts ratio[8] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment