Created
March 25, 2019 10:01
-
-
Save Mehonoshin/f0496cc5ef1982df655e8c36fd6a4bb3 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
class Movie | |
attr_accessor :link, :movie, :year, :country, :showing, :jenre, :length, :value, :director, :actor | |
def initialize(link, movie, year, country, showing, jenre, length, value, director, actor) | |
@link = link | |
@movie = movie | |
@year = year | |
@country = country | |
@showing = showing | |
@jenre = jenre | |
@length = length | |
@value = value | |
@director = director | |
@actor = actor | |
end | |
end | |
class MovieCollection | |
attr_accessor :file | |
def initialize(file) | |
@file = file | |
@movies = [] | |
read_file | |
end | |
def read_file | |
File.readlines(@file).each do |line| | |
params = line.split("|") | |
new_movie = Movie.new(params[0], params[1], params[2], params[3], | |
params[4], params[5], params[6], params[7], params[8], params[9]) | |
@movies.push(new_movie) | |
end | |
end | |
def all | |
@movies | |
end | |
end | |
collection = MovieCollection.new("movies.txt") | |
p collection.all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment