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

Maksim Filipenko - 0 #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
33 changes: 33 additions & 0 deletions __Maxim-Filipenko__/0/first.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require 'roo'

# Class of finding products
class Finder
def initialize
@a = Roo::Spreadsheet.open 'file1.xlsx'
@answer = gets.chomp.upcase
@result = []
end

def making_a_product_list
@array1 = @a.sheet(0).column(1)
@array2 = @a.sheet(0).column(15)
@list = {}

([email protected]).each do |i|
Copy link
Collaborator

Choose a reason for hiding this comment

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

@array1.zip(@array2).each do |v1, v2|
...(v1, v2)

@list.store(@array1[i], @array2[i])
Copy link
Collaborator

Choose a reason for hiding this comment

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

list[@array1[i]] = @array2[i]

end
@list.delete_if { |_k, v| v.nil? }
end

def searcher
Copy link
Collaborator

Choose a reason for hiding this comment

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

better name - search

making_a_product_list
@list.each do |k, v|
@result.push("The #{k} is #{v} BYN in Minsk these days") if k.to_s.include? @answer
end
puts @result
print "#{@answer} can not be found in our data base !" if @result[0].nil?
end
end

puts 'What product do you need ?'
Finder.new.searcher