Skip to content

Instantly share code, notes, and snippets.

@Prigin
Created October 13, 2019 00:10
Show Gist options
  • Save Prigin/b6bae1dca2602c41676c1d3d0eac4ca7 to your computer and use it in GitHub Desktop.
Save Prigin/b6bae1dca2602c41676c1d3d0eac4ca7 to your computer and use it in GitHub Desktop.
try
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