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
movie = ARGV[0] | |
list = {"Titanic" => "Titanic is a bad movie", | |
"Matrix" => "Matrix is a good movie"} | |
if movie | |
res = list[movie] | |
if res | |
puts res | |
else |
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
movie = ARGV[0] | |
goodlist = ["Braveheart", "Matrix", "Lord os the Rings"] | |
badlist = ["Twilight", "Titanic"] | |
if movie | |
if goodlist.include?(movie) | |
puts "#{movie} is pretty good." | |
elsif badlist.include?(movie) | |
puts "#{movie} is not worth watching." |
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
doc = ARGV[0] | |
def Output (file) | |
print "[search]> " | |
@search = gets.chomp # how to avoid THIS?! | |
file.readlines.each do |line| | |
line = line.split("|") | |
if line[1].include?(@search) # how to avoid THIS?! | |
print line[1] + " | " |
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
doc = ARGV[0] | |
print "[search]> " | |
search = gets.chomp | |
if doc | |
if File.exist?(doc) | |
file = File.open(doc) | |
else | |
puts "no such file" | |
end | |
else |
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
doc = ARGV[0] | |
doc = "movies.txt" if doc == nil | |
unless File.exist?(doc) | |
puts "no such file" | |
exit | |
end | |
print "[search]> "; search = "Max"; puts search |
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
doc = ARGV[0] || "movies.txt" | |
unless File.exist?(doc) | |
puts "no such file" | |
exit | |
end | |
print "[search]> "; search = "Max"; puts search | |
File.foreach(doc) do |line| | |
line = line.split("|") |
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
mas = [] | |
doc = "movies.txt" | |
syms = [:link, :title, :year, :country, | |
:date, :genre, :duration, | |
:rating, :director, :stars] | |
buff = {} | |
i = 0 | |
File.foreach(doc) do |line| | |
line.chomp! |
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
mas = [] | |
doc = "movies.txt" | |
syms = [:link, :title, :year, :country, | |
:date, :genre, :duration, | |
:rating, :director, :stars] | |
File.foreach(doc){ |line| | |
mas.append(syms.zip(line.chomp.split("|")).to_h) } | |
def Show_em (mas) |
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
doc = "movies.txt" | |
syms = [:link, :title, :year, :country, | |
:date, :genre, :duration, | |
:rating, :director, :stars] | |
mas = File.foreach(doc).map{|line| syms.zip(line.chomp.split("|")).to_h} | |
def Show_em (array_hash) | |
array_hash.each do |unit| | |
puts unit[:title] + " (" + unit[:date] + "; " + unit[:genre] +") - " + unit[:duration] | |
end |
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) |
OlderNewer