Skip to content
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
3 changes: 3 additions & 0 deletions Task 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
array1 = ["apple", "onion", "orange"]
array2 = ["apple", "onion", "orange", "Sugar"]
array1 & array2
3 changes: 3 additions & 0 deletions Task 8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
numbers = [45, 3123, 2141, 387, 15463, 6]
numbers.sort! {|x, y| y <=> x}
puts numbers
6 changes: 6 additions & 0 deletions Task5
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Home
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong realization of task. The script should take the NAME OF TEXT FILE and the LINE.

def initialize(color)
@color = color
end
end
p Home.new(1).method(:initialize).source_location
15 changes: 15 additions & 0 deletions ruby/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM ruby:2.6.5

RUN apt-get update && apt-get install -qq -y build-essential git nodejs libpq-dev cmake libgit2-dev pkg-config nano htop wget tar

RUN mkdir /app
WORKDIR /app

ENV GEM_HOME /bundle
ENV BUNDLE_PATH /bundle
RUN gem install bundler --no-document
RUN bundle config git.allow_insecure true
COPY Gemfile ./
COPY Gemfile.lock ./

RUN bundle install
9 changes: 9 additions & 0 deletions ruby/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: '3'
services:
ruby:
container_name: ruby
build: .
volumes:
- .:/app:rw
tty: true
stdin_open: true
22 changes: 22 additions & 0 deletions task 6
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class Numbers
def sum(number, other)
number + other
end

def difference(number, other)
number - other
end

def multiplication(number, other)
number * other
end

def division(number, other)
number / other
end
end
calculator = Numbers.new
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In example to task 6 you can see next Input example: ruby yourscript.rb 5 10 sum. So you need to give argument to this script (two numbers and operation name).

puts calculator.sum(5, 10)
puts calculator.difference(5, 10)
puts calculator.multiplication(5, 10)
puts calculator.division(5, 10)
5 changes: 4 additions & 1 deletion n_ew.rb → task 7
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ class New
def task
myArray = ["stuff", "widget", "ruby", "goodies", "java", "emerald", "etc" ]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this script must take arguments from outside (ARGV), so you should give these argument when you call this script

item = myArray[rand(myArray.length)]
puts item
end
end
a = New.new
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should create instance outside of class body

a.task
end