Skip to content

Instantly share code, notes, and snippets.

View Nursultan91's full-sized avatar
🎯
Focusing

Nursultan Kuzhagaliyev Nursultan91

🎯
Focusing
  • Almaty, Kazakhstan
View GitHub Profile
@Nursultan91
Nursultan91 / main.rb
Created April 14, 2019 16:45
Выдвет ошибку
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"
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]
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
@Nursultan91
Nursultan91 / csv.rb
Created March 2, 2018 12:06
Вот весь код касающийся этого задания
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]
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
@Nursultan91
Nursultan91 / ranking_test.rb
Created February 27, 2018 11:42
Тестовый файл
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
@Nursultan91
Nursultan91 / ranking.rb
Last active February 27, 2018 08:26
Второе задание
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
@Nursultan91
Nursultan91 / moviespro.rb
Created February 21, 2018 17:56
Усложненная версия первого домашнего задания
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"}
@Nursultan91
Nursultan91 / movies.rb
Created February 21, 2018 17:44
Первое задание по квесту
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
@Nursultan91
Nursultan91 / routes.rb
Created January 17, 2018 12:59
Пусть в config/routes.rb пропишут так
devise_for :users, :path => '', :path_names => {:sign_in => 'login', :sign_out => 'logout', :edit => 'profile'},
:controllers => {:omniauth_callbacks => "omniauth_callbacks", registrations: 'users/registrations'}