Created
October 13, 2019 00:10
-
-
Save Prigin/b6bae1dca2602c41676c1d3d0eac4ca7 to your computer and use it in GitHub Desktop.
try
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
require 'csv' | |
require 'ostruct' | |
doc = "movies.txt" | |
syms = [:link, :title, :year, :country, | |
:date, :genre, :duration, | |
:rating, :director, :stars] | |
#mas = OpenStruct.new | |
mas = CSV.readlines(doc, {headers: syms, col_sep: "|"}) | |
def Show_em (array_hash) | |
array_hash.each do |unit| | |
puts unit[:title] + " (" + unit[:date] + "; " + unit[:genre] +") - " + unit[:duration] | |
end | |
end | |
Show_em mas.max_by(5){|a| a[:duration].split(" ").first.to_i} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment