This file contains hidden or 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
| if ARGV[0] != nil | |
| filename = ARGV[0] | |
| else | |
| filename = File.open("movies.txt", "r") | |
| end | |
| File.readlines(filename).each do |line| | |
| movies = line.split("|") | |
| if movies[1].include? "Max" | |
| rank = (movies[7].to_f*10 - 80).to_i |
This file contains hidden or 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
| filename = ARGV.first || 'movies.txt' | |
| abort("Файл не найден") unless File.exist?(filename) | |
| File.readlines(filename).each do |line| | |
| movie_hash = Hash[ [:link, :title, :year, :country, :premiere, :genre, :length, :rank, :cast].zip(line.split("|")) ] | |
| end |
This file contains hidden or 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
| require 'csv' | |
| require 'ostruct' | |
| require 'date' | |
| filename = ARGV.first || 'movies.txt' | |
| abort("Файл не найден") unless File.exist?(filename) | |
| FIELDS = %i[link title year country premiere genre duration rank director cast] |
This file contains hidden or 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
| class MovieCollection | |
| FIELDS = %i[link title year country premiere genre duration rank director cast] | |
| def initialize(filename) | |
| @file = filename | |
| end | |
| def all | |
| @@all = File.readlines(@file) | |
| .map { |line| FIELDS.zip(line.split("|")).to_h } | |
| end |
This file contains hidden or 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
| require 'csv' | |
| require 'ostruct' | |
| require 'date' | |
| filename = ARGV.first || 'movies.txt' | |
| abort("Файл не найден") unless File.exist?(filename) | |
| FIELDS = %i[link title year country premiere genre duration rank director cast] |
This file contains hidden or 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
| require_relative 'drink' | |
| require_relative 'purchase' | |
| coce = Drink.new("CocaCola", "CC", 1.50) | |
| pepsi = Drink.new("PepsiCola", "PC", 2.00) | |
| water = Drink.new("Water", "WA", 0.85) | |
| def drink_busket | |
| puts "Write list of your drinks as it show in Example" | |
| puts "Example: CC PC WA CC" |
OlderNewer