parent
db00f79e72
commit
8d8cc46bde
@ -1,16 +0,0 @@
|
||||
require_relative '../src/02_user_interface.rb'
|
||||
|
||||
RSpec.describe "Main" do
|
||||
before do
|
||||
allow(STDIN).to receive(:gets).and_return("ruby\n")
|
||||
end
|
||||
|
||||
it "greets the user and checks Ruby as language" do
|
||||
expect { main() }.to output("Hello my catgirl test_user! \nWhat is your love language?\nruby\nc++\npy\nПодлиза \n").to_stdout
|
||||
end
|
||||
|
||||
it "handles unknown language input" do
|
||||
allow(STDIN).to receive(:gets).and_return("java\n")
|
||||
expect { main() }.to output(/Неизвестный язык: java/).to_stdout
|
||||
end
|
||||
end
|
@ -1,2 +0,0 @@
|
||||
puts "Hello, world!"
|
||||
|
@ -1,30 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
LANGUAGES = [
|
||||
"ruby",
|
||||
"c++",
|
||||
"py"
|
||||
]
|
||||
|
||||
def main()
|
||||
user_name = ARGV[0]
|
||||
puts "Hello my catgirl #{user_name}! \nWhat is your love language?"
|
||||
LANGUAGES.each { |language| puts "#{language}", " " }
|
||||
|
||||
user_lang = STDIN.gets.chomp
|
||||
|
||||
case user_lang
|
||||
when "ruby"
|
||||
puts "Подлиза \n"
|
||||
when "c++"
|
||||
puts "MATLAB скушал? \n"
|
||||
when "TS/JS"
|
||||
puts "Фронтендер, Фууу! \n"
|
||||
when "py"
|
||||
puts "Девопсер, иди ДАГИ писать \n"
|
||||
else
|
||||
puts "Неизвестный язык: #{user_lang}"
|
||||
end
|
||||
end
|
||||
|
||||
main()
|
@ -1,39 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
LANGUAGES = [
|
||||
"ruby",
|
||||
"c++",
|
||||
"py"
|
||||
]
|
||||
|
||||
def main()
|
||||
user_name = ARGV[0]
|
||||
puts "Hello my catgirl #{user_name}! \nWhat is your love language?"
|
||||
LANGUAGES.each { |language| puts "#{language}", " " }
|
||||
|
||||
user_lang = STDIN.gets.chomp
|
||||
case user_lang
|
||||
when "ruby"
|
||||
puts "Подлиза \n"
|
||||
when "c++"
|
||||
puts "MATLAB скушал? \n"
|
||||
when "TS/JS"
|
||||
puts "Фронтендер, Фууу! \n"
|
||||
when "py"
|
||||
puts "Девопсер, иди ДАГИ писать \n"
|
||||
end
|
||||
|
||||
puts "Введите команду на языке Ruby для выполнения:"
|
||||
ruby_command = STDIN.gets.chomp
|
||||
begin
|
||||
eval(ruby_command)
|
||||
rescue Exception => e
|
||||
puts "Ошибка выполнения команды Ruby: #{e.message}"
|
||||
end
|
||||
|
||||
puts "Введите команду операционной системы для выполнения:"
|
||||
os_command = STDIN.gets.chomp
|
||||
system(os_command)
|
||||
end
|
||||
|
||||
main()
|
@ -1,4 +0,0 @@
|
||||
# Lab 2
|
||||
|
||||
> "И тут я обнаружил что случайно сделал 3-5 задачи в 1-2"
|
||||
|
@ -1,33 +0,0 @@
|
||||
class Student
|
||||
attr_accessor :id, :surname, :name, :patronymic, :phone, :telegram, :email, :git
|
||||
|
||||
def self.valid_phone_number?(phone)
|
||||
phone.match?(/\A\+?[0-9]{10,15}\z/)
|
||||
end
|
||||
|
||||
def initialize(args = {})
|
||||
@surname = args.fetch(:surname)
|
||||
@name = args.fetch(:name)
|
||||
@patronymic = args.fetch(:patronymic)
|
||||
|
||||
@id = args[:id] || nil
|
||||
|
||||
@phone = args[:phone]
|
||||
if @phone && !Student.valid_phone_number?(@phone)
|
||||
raise ArgumentError, "Invalid phone number format: #{@phone}"
|
||||
end
|
||||
|
||||
@telegram = args[:telegram] || nil
|
||||
@email = args[:email] || nil
|
||||
@git = args[:git] || nil
|
||||
end
|
||||
|
||||
def to_s
|
||||
"Student: #{@surname} #{@name} #{@patronymic}\n" \
|
||||
"ID: #{@id || 'N/A'}\n" \
|
||||
"Phone: #{@phone || 'N/A'}\n" \
|
||||
"Telegram: #{@telegram || 'N/A'}\n" \
|
||||
"Email: #{@email || 'N/A'}\n" \
|
||||
"Git: #{@git || 'N/A'}"
|
||||
end
|
||||
end
|
Loading…
Reference in new issue