Skip to content

Instantly share code, notes, and snippets.

@Mehonoshin
Created March 25, 2019 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mehonoshin/f0496cc5ef1982df655e8c36fd6a4bb3 to your computer and use it in GitHub Desktop.
Save Mehonoshin/f0496cc5ef1982df655e8c36fd6a4bb3 to your computer and use it in GitHub Desktop.
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