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_film = 'Matrix' | |
bad_film = 'Titanic' | |
definition = ARGV[0] | |
if definition == good_film | |
puts good_film.to_s + ' is a good movie' | |
elsif definition == bad_film | |
puts bad_film.to_s + ' is a bad movie' | |
else | |
puts 'Haven\'t seen ' + ARGV[0].to_s | |
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
# file_name = '/Users/VictorK/ROR2/movies.txt' — используется при установке дефолтного значения | |
time_film = ARGV[1].to_s #используется при вводе аргументов из консоли | |
file_name = ARGV[0].to_s | |
if ARGV.empty? | |
# ARGV[0] = file_name — используется при установке дефолтного значения | |
puts 'Вы не ввели название файла, повторите попытку:' | |
file_name = gets.chomp | |
if file_name != 'movies.txt' | |
puts 'Данного файла не существует' | |
abort |
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 Station | |
attr_accessor :name | |
trains = [] | |
def initialize(name) | |
@name = name | |
end | |
def add_train (train_obj) | |
trains << train_obj |
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 Train | |
attr_accessor :number | |
attr_accessor :type | |
attr_accessor :wagons_count | |
attr_accessor :speed | |
attr_accessor :current_route | |
def initialize(number, type, wagons_count) | |
@trains_type = ["passanger", "cargo"] | |
if @trains_type.include?(type) |
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
16.31.123.119 - - [21/Sep/2016:23:52:40 +0800] "GET / HTTP/1.0" 200 15076 "-" "Mozilla/5.0 (compatible; PRTG Network Monitor (www.paessler.com); Windows)" | |
116.31.123.119 - - [21/Sep/2016:23:52:44 +0800] "GET / HTTP/1.0" 200 15076 "http://mp.weixinbridge.com/mp/wapredirect?url=https%3A%2F%2Fdoctorcash.cn%2F" "Mozilla/5.0 (Linux; Android 5.1; OPPO R9tm Build/LMY47I) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/37.0.0.0 Mobile MQQBrowser/6.8 TBS/036824 Safari/537.36 MicroMessenger/6.3.25.861 NetType/WIFI Language/zh_CN" | |
116.31.123.119 - - [21/Sep/2016:23:52:45 +0800] "GET /assets/fontawesome-webfont-a7c7e4930090e038a280fd61d88f0dc03dad4aeaedbd8c9be3dd9aa4c3b6f8d1.woff?v=4.4.0 HTTP/1.0" 200 65267 "https://doctorcash.cn/assets/application-759276df1ad70dc86026946b4372f981cdf0fec51974b10445bf7f8ccca1127b.css" "Mozilla/5.0 (Linux; Android 5.1; OPPO R9tm Build/LMY47I) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/37.0.0.0 Mobile MQQBrowser/6.8 TBS/036824 Safari/537.36 MicroMessenger/6.3.25.861 |
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
# Recang method calculation | |
class RectangleMethod | |
include Enumerable | |
def initialize(a, b, n = 1000) | |
@a, @b, @n = a, b, n | |
end | |
def calc_rectang | |
# @result = 0 | |
interval = (@b - @a).fdiv @n |
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
File.open(ARGV[0]).each_line do |line| # эта штука нормально вытаскивает построчно контент и конвертит строчку в массив | |
s = line.split("") # вопрос в том, как мне строчку сохранить в отдельный массив, чтобы до него можно было достучаться | |
end # в методе counting_point_mutations, ну или просто сохранить каждую строку в отдельную переменную | |
def counting_point_mutations(string1, string2) | |
s1 = string1.split("") | |
s2 = string2.split("") | |
result = 0 | |
s1.zip(s2).map { |x, y| result +=1 unless x == y } # вот такая оптимизация получилась | |
p result |
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 Numbers | |
def initialize(str) | |
@str = str | |
@str_arr = str.split("").map(&:to_i) #создаю массив цифр из строки | |
end | |
def take_sequence | |
@mega_result = Array.new | |
@str_arr.each_index do |i| | |
result = Array.new |
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
def monotonic? (arr) | |
p arr.length | |
arr.each_index do |i| | |
if arr.length - 1 == i || arr.length == 0 | |
p 'debug' | |
break | |
else | |
if arr[i + 1] - arr[i] == 1 | |
return true | |
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] | |
g_movies = ["Matrix","HP"] | |
b_movies = ["Titanic"] | |
if g_movies.include?(movie) | |
p "#{movie} is a good movie!" | |
elsif b_movies.include?(movie) | |
p "#{movie} is a bad movie!" | |
else |
OlderNewer