Skip to content

Commit

Permalink
Make first level
Browse files Browse the repository at this point in the history
  • Loading branch information
40grivenprog committed Dec 9, 2018
1 parent 2391768 commit 89a5db0
Showing 1 changed file with 33 additions and 0 deletions.
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 = {}

(0...@array1.length).each do |i|
@list.store(@array1[i], @array2[i])
end
@list.delete_if { |_k, v| v.nil? }
end

def searcher
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

0 comments on commit 89a5db0

Please sign in to comment.