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_relative 'drink' | |
require_relative 'purchase' | |
coce = Drink.new("CocaCola", "CC", 1.50) | |
pepsi = Drink.new("PepsiCola", "PC", 2.00) | |
water = Drink.new("Water", "WA", 0.85) | |
def drink_busket | |
puts "Write list of your drinks as it show in Example" | |
puts "Example: CC PC WA CC" |
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' | |
require 'date' | |
filename = ARGV.first || 'movies.txt' | |
abort("Файл не найден") unless File.exist?(filename) | |
FIELDS = %i[link title year country premiere genre duration rank director cast] |
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 |
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' | |
require 'date' | |
filename = ARGV.first || 'movies.txt' | |
abort("Файл не найден") unless File.exist?(filename) | |
FIELDS = %i[link title year country premiere genre duration rank director cast] |
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
filename = ARGV.first || 'movies.txt' | |
abort("Файл не найден") unless File.exist?(filename) | |
File.readlines(filename).each do |line| | |
movie_hash = Hash[ [:link, :title, :year, :country, :premiere, :genre, :length, :rank, :cast].zip(line.split("|")) ] | |
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
if ARGV[0] != nil | |
filename = ARGV[0] | |
else | |
filename = File.open("movies.txt", "r") | |
end | |
File.readlines(filename).each do |line| | |
movies = line.split("|") | |
if movies[1].include? "Max" | |
rank = (movies[7].to_f*10 - 80).to_i |
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
if ARGV.length != 1 | |
puts "We need exactly one parameter. The name of a file." | |
exit; | |
end | |
filename = ARGV[0] | |
puts "Going to open '#{filename}'" | |
fh = open filename |
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
good_movies = [ 'Matrix', 'GOT', 'Hobbit', 'LOTR', 'Batman' ] | |
bad_movies = [ 'Titanic', 'Terminator', 'Cloverfield', 'Vikings', 'WD' ] | |
bad_answer = bad_movies & ARGV | |
bad_answer.each { |ba| puts "#{ba} is a bad movie"} | |
good_answer = good_movies & ARGV | |
good_answer.each { |ga| puts "#{ga} is a good movie"} |
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
if ARGV.include? "Titanic" | |
puts "Titanic is a bad movie" | |
elsif ARGV.include? "Matrix" | |
puts "Matrix is a good movie" | |
else | |
puts "Haven't seen #{ARGV} yet" | |
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
devise_for :users, :path => '', :path_names => {:sign_in => 'login', :sign_out => 'logout', :edit => 'profile'}, | |
:controllers => {:omniauth_callbacks => "omniauth_callbacks", registrations: 'users/registrations'} |
NewerOlder