Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lab5 #1

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: 2.1
jobs:
build:
machine:
image: ubuntu-2004:202101-01

steps:
- checkout
- run: |
sudo apt-get update
sudo apt-get install ruby

- run: |
sudo apt-get update
sudo apt-get install rubocop
gem install rubocop-rspec
- run: |
gem install reek
- run: |
sudo apt-get install libboost-all-dev
- run: |
ruby test.rb
rubocop .
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
lab.rb
/.vscode
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[![CircleCI](https://circleci.com/gh/Dan1aR/ruby_lab/tree/lab5.svg?style=shield)](https://circleci.com/gh/Dan1aR/ruby_lab/tree/lab5)


# ruby_lab
Андреев Данил ИУ6-33Б - Лабораторные работы по ЯИП
14 changes: 14 additions & 0 deletions funcmodule.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

def calc_f(x_param, y_param)
((x_param - 1).abs**0.5 - y_param.abs**0.5) / (1 + x_param**2 / 2 + y_param**2 / 4)
end

def decrypt_str(str)
str.force_encoding('UTF-8')
abc = 'абвгдеёжзийклмнопрстуфхцчшщъыьэюя'
str.each_char.map do |s_i|
c = s_i.eql?(' ') ? ' ' : abc[(abc.index(s_i.downcase) + 1) % abc.length]
/[[:upper:]]/.match(s_i) ? c.upcase : c
end.join('')
end
11 changes: 11 additions & 0 deletions main.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

require_relative 'funcmodule'

puts('Enter x, y:')
x, y = gets.split.map(&:to_f)
puts calc_f(x, y)

puts('Enter your string:')
str = gets.chomp
puts "#{str.force_encoding('UTF-8')} :: #{decrypt_str(str)}"
16 changes: 16 additions & 0 deletions test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: false

require 'minitest/autorun'
require_relative 'funcmodule'

# Lab5 Testing class
class TestRobot < Minitest::Test
def test_calc_f
jpyatachkov marked this conversation as resolved.
Show resolved Hide resolved
assert_in_delta(-0.0021352323706365726, calc_f(10, 10), 0.000001)
end

def test_decrypt_str
test_str = 'Привет это строка'
assert_equal 'Рсйгёу юуп тусплб', decrypt_str(test_str)
end
end