Created
March 3, 2018 17:13
-
-
Save Nursultan91/4289308a382c525a7aaaf738329590eb 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 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 | |
def sort_by_the(argument) | |
@argument = argument.to_s | |
@sorted_collection = @@all.sort_by { |movie| movie[@argument].to_i } | |
puts @sorted_collection | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment