{"action":"created","comment":{"url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/pulls/comments/240035971","pull_request_review_id":182977168,"id":240035971,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MDAzNTk3MQ==","diff_hunk":"@@ -0,0 +1,170 @@\n+require 'roo'\n+require 'roo-xls'\n+MINSK_COL = 14\n+class PriceSearcher\n+  def initialize\n+    @last_table = Roo::Excelx.new('./data/Average_prices(serv)-10-2018.xlsx')\n+    @name = ''\n+    @result = @minmax = []\n+    @similar = {}\n+  end\n+\n+  def input_name\n+    puts \"\\nThe price of what product are you looking for?\"\n+    @name = gets.chomp\n+  end\n+\n+  def find_price\n+    name = input_name.upcase\n+    @last_table.select { |el| !el[0].nil? && (el[0] =~ /#{name}[., )]{1}/ || el[0] == name) }.each do |elem|\n+      @result << elem\n+    end\n+  end\n+\n+  def parse_results\n+    find_price\n+    out_price\n+    return if @result.empty?\n+\n+    MinMax.new(@result, @name, @last_table).out\n+    search_similar_price_elems\n+    out_similar\n+  end\n+\n+  def out_price\n+    case @result.length\n+    when 0 then\n+      puts \"'#{@name}' can not be found in database.\"\n+    when 1 then\n+      puts \"'#{@name}' is #{@result[0][MINSK_COL]} BYN in Minsk these days.\"\n+    else\n+      @result.each do |elem|\n+        puts \"'#{@name}'(#{elem[0].capitalize.gsub(/\\s+/, ' ')}) is #{elem[MINSK_COL]} BYN in Minsk these days.\"\n+      end\n+    end\n+  end\n+\n+  def search_similar_price_elems\n+    @result.each do |res|\n+      @similar[res[0].to_sym] = []\n+      @last_table.each do |elem|\n+        @similar[res[0].to_sym] << elem if elem[MINSK_COL].to_f != 0 && similar?(elem, res)\n+      end\n+    end\n+  end\n+\n+  def similar?(elem, res)\n+    elem[MINSK_COL].to_f > res[MINSK_COL] - 0.25 && elem[MINSK_COL].to_f < res[MINSK_COL] + 0.25\n+  end\n+\n+  def out_similar\n+    if @result.length == 1\n+      puts \"For similar price you also can afford #{similar_elements(@similar[@similar.keys[0]])}.\"\n+    else\n+      @similar.each do |key, value|\n+        puts \"For similar price as '#{key.to_s.capitalize.gsub(/\\s+/, ' ')}'\\\n+you also can afford #{similar_elements(value)}.\"\n+      end\n+    end\n+  end\n+\n+  def similar_elements(similar)\n+    out = ''\n+    similar.each do |sim|\n+      if sim[0].match?(/#{@name.upcase}[., )]{1}/) || sim[0] == @name.upcase\n+        similar.delete_at(similar.index(sim))\n+        next\n+      end\n+      out += \"'#{sim[0].capitalize.gsub(/\\s+/, ' ')}'\" + ','\n+    end\n+    out[0...-1]\n+  end\n+end\n+\n+class MinMax\n+  def initialize(results, name, last_table)\n+    @results = results\n+    @all_tables = []\n+    @name = name\n+    @last_table = last_table\n+  end\n+\n+  def all_tables\n+    minmax = []\n+    Dir.foreach('./data') do |file|\n+      case File.extname(file)\n+      when '.xlsx' then\n+        minmax << Roo::Excelx.new(\"./data/#{file}\")","path":"Maxim Oberemko/0/parse.rb","position":97,"original_position":97,"commit_id":"0b62c4fa8b1960ab0f7d61351ffae56fb08fa35c","original_commit_id":"0b62c4fa8b1960ab0f7d61351ffae56fb08fa35c","user":{"login":"RGBD","id":8408991,"node_id":"MDQ6VXNlcjg0MDg5OTE=","avatar_url":"https://avatars2.githubusercontent.com/u/8408991?v=4","gravatar_id":"","url":"https://api.github.com/users/RGBD","html_url":"https://github.com/RGBD","followers_url":"https://api.github.com/users/RGBD/followers","following_url":"https://api.github.com/users/RGBD/following{/other_user}","gists_url":"https://api.github.com/users/RGBD/gists{/gist_id}","starred_url":"https://api.github.com/users/RGBD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RGBD/subscriptions","organizations_url":"https://api.github.com/users/RGBD/orgs","repos_url":"https://api.github.com/users/RGBD/repos","events_url":"https://api.github.com/users/RGBD/events{/privacy}","received_events_url":"https://api.github.com/users/RGBD/received_events","type":"User","site_admin":false},"body":"Roo::Spreadsheet, открывает оба типа","created_at":"2018-12-09T13:02:03Z","updated_at":"2018-12-09T13:11:21Z","html_url":"https://github.com/rubizza-survival-camp/winter-2018/pull/1#discussion_r240035971","pull_request_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/pulls/1","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/pulls/comments/240035971"},"html":{"href":"https://github.com/rubizza-survival-camp/winter-2018/pull/1#discussion_r240035971"},"pull_request":{"href":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/pulls/1","id":235220175,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM1MjIwMTc1","html_url":"https://github.com/rubizza-survival-camp/winter-2018/pull/1","diff_url":"https://github.com/rubizza-survival-camp/winter-2018/pull/1.diff","patch_url":"https://github.com/rubizza-survival-camp/winter-2018/pull/1.patch","issue_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/issues/1","number":1,"state":"open","locked":false,"title":"Maxim Oberemko - 0","user":{"login":"obmax","id":43636948,"node_id":"MDQ6VXNlcjQzNjM2OTQ4","avatar_url":"https://avatars3.githubusercontent.com/u/43636948?v=4","gravatar_id":"","url":"https://api.github.com/users/obmax","html_url":"https://github.com/obmax","followers_url":"https://api.github.com/users/obmax/followers","following_url":"https://api.github.com/users/obmax/following{/other_user}","gists_url":"https://api.github.com/users/obmax/gists{/gist_id}","starred_url":"https://api.github.com/users/obmax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/obmax/subscriptions","organizations_url":"https://api.github.com/users/obmax/orgs","repos_url":"https://api.github.com/users/obmax/repos","events_url":"https://api.github.com/users/obmax/events{/privacy}","received_events_url":"https://api.github.com/users/obmax/received_events","type":"User","site_admin":false},"body":"## Name\r\nMaxim Oberemko\r\n\r\n## Homework#\r\n0\r\n\r\n## Link to video with demo\r\nhttps://www.youtube.com/watch?v=VPtjjMbaYQs&feature=youtu.be\r\n\r\n## Comment\r\nAll levels.\r\n","created_at":"2018-12-01T21:35:29Z","updated_at":"2018-12-09T13:11:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9cd62f97605bc08bda04b8adeaf56e85b73242a2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/pulls/1/commits","review_comments_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/pulls/1/comments","review_comment_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/issues/1/comments","statuses_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/statuses/0b62c4fa8b1960ab0f7d61351ffae56fb08fa35c","head":{"label":"obmax:homework_0","ref":"homework_0","sha":"0b62c4fa8b1960ab0f7d61351ffae56fb08fa35c","user":{"login":"obmax","id":43636948,"node_id":"MDQ6VXNlcjQzNjM2OTQ4","avatar_url":"https://avatars3.githubusercontent.com/u/43636948?v=4","gravatar_id":"","url":"https://api.github.com/users/obmax","html_url":"https://github.com/obmax","followers_url":"https://api.github.com/users/obmax/followers","following_url":"https://api.github.com/users/obmax/following{/other_user}","gists_url":"https://api.github.com/users/obmax/gists{/gist_id}","starred_url":"https://api.github.com/users/obmax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/obmax/subscriptions","organizations_url":"https://api.github.com/users/obmax/orgs","repos_url":"https://api.github.com/users/obmax/repos","events_url":"https://api.github.com/users/obmax/events{/privacy}","received_events_url":"https://api.github.com/users/obmax/received_events","type":"User","site_admin":false},"repo":{"id":159864261,"node_id":"MDEwOlJlcG9zaXRvcnkxNTk4NjQyNjE=","name":"winter-2018","full_name":"obmax/winter-2018","private":false,"owner":{"login":"obmax","id":43636948,"node_id":"MDQ6VXNlcjQzNjM2OTQ4","avatar_url":"https://avatars3.githubusercontent.com/u/43636948?v=4","gravatar_id":"","url":"https://api.github.com/users/obmax","html_url":"https://github.com/obmax","followers_url":"https://api.github.com/users/obmax/followers","following_url":"https://api.github.com/users/obmax/following{/other_user}","gists_url":"https://api.github.com/users/obmax/gists{/gist_id}","starred_url":"https://api.github.com/users/obmax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/obmax/subscriptions","organizations_url":"https://api.github.com/users/obmax/orgs","repos_url":"https://api.github.com/users/obmax/repos","events_url":"https://api.github.com/users/obmax/events{/privacy}","received_events_url":"https://api.github.com/users/obmax/received_events","type":"User","site_admin":false},"html_url":"https://github.com/obmax/winter-2018","description":null,"fork":true,"url":"https://api.github.com/repos/obmax/winter-2018","forks_url":"https://api.github.com/repos/obmax/winter-2018/forks","keys_url":"https://api.github.com/repos/obmax/winter-2018/keys{/key_id}","collaborators_url":"https://api.github.com/repos/obmax/winter-2018/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/obmax/winter-2018/teams","hooks_url":"https://api.github.com/repos/obmax/winter-2018/hooks","issue_events_url":"https://api.github.com/repos/obmax/winter-2018/issues/events{/number}","events_url":"https://api.github.com/repos/obmax/winter-2018/events","assignees_url":"https://api.github.com/repos/obmax/winter-2018/assignees{/user}","branches_url":"https://api.github.com/repos/obmax/winter-2018/branches{/branch}","tags_url":"https://api.github.com/repos/obmax/winter-2018/tags","blobs_url":"https://api.github.com/repos/obmax/winter-2018/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/obmax/winter-2018/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/obmax/winter-2018/git/refs{/sha}","trees_url":"https://api.github.com/repos/obmax/winter-2018/git/trees{/sha}","statuses_url":"https://api.github.com/repos/obmax/winter-2018/statuses/{sha}","languages_url":"https://api.github.com/repos/obmax/winter-2018/languages","stargazers_url":"https://api.github.com/repos/obmax/winter-2018/stargazers","contributors_url":"https://api.github.com/repos/obmax/winter-2018/contributors","subscribers_url":"https://api.github.com/repos/obmax/winter-2018/subscribers","subscription_url":"https://api.github.com/repos/obmax/winter-2018/subscription","commits_url":"https://api.github.com/repos/obmax/winter-2018/commits{/sha}","git_commits_url":"https://api.github.com/repos/obmax/winter-2018/git/commits{/sha}","comments_url":"https://api.github.com/repos/obmax/winter-2018/comments{/number}","issue_comment_url":"https://api.github.com/repos/obmax/winter-2018/issues/comments{/number}","contents_url":"https://api.github.com/repos/obmax/winter-2018/contents/{+path}","compare_url":"https://api.github.com/repos/obmax/winter-2018/compare/{base}...{head}","merges_url":"https://api.github.com/repos/obmax/winter-2018/merges","archive_url":"https://api.github.com/repos/obmax/winter-2018/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/obmax/winter-2018/downloads","issues_url":"https://api.github.com/repos/obmax/winter-2018/issues{/number}","pulls_url":"https://api.github.com/repos/obmax/winter-2018/pulls{/number}","milestones_url":"https://api.github.com/repos/obmax/winter-2018/milestones{/number}","notifications_url":"https://api.github.com/repos/obmax/winter-2018/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/obmax/winter-2018/labels{/name}","releases_url":"https://api.github.com/repos/obmax/winter-2018/releases{/id}","deployments_url":"https://api.github.com/repos/obmax/winter-2018/deployments","created_at":"2018-11-30T18:38:02Z","updated_at":"2018-11-30T18:38:05Z","pushed_at":"2018-12-06T19:59:39Z","git_url":"git://github.com/obmax/winter-2018.git","ssh_url":"git@github.com:obmax/winter-2018.git","clone_url":"https://github.com/obmax/winter-2018.git","svn_url":"https://github.com/obmax/winter-2018","homepage":null,"size":40,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rubizza-survival-camp:master","ref":"master","sha":"239176854cd958c2c990eaf651bbb394d0fc6345","user":{"login":"rubizza-survival-camp","id":40864986,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQwODY0OTg2","avatar_url":"https://avatars1.githubusercontent.com/u/40864986?v=4","gravatar_id":"","url":"https://api.github.com/users/rubizza-survival-camp","html_url":"https://github.com/rubizza-survival-camp","followers_url":"https://api.github.com/users/rubizza-survival-camp/followers","following_url":"https://api.github.com/users/rubizza-survival-camp/following{/other_user}","gists_url":"https://api.github.com/users/rubizza-survival-camp/gists{/gist_id}","starred_url":"https://api.github.com/users/rubizza-survival-camp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rubizza-survival-camp/subscriptions","organizations_url":"https://api.github.com/users/rubizza-survival-camp/orgs","repos_url":"https://api.github.com/users/rubizza-survival-camp/repos","events_url":"https://api.github.com/users/rubizza-survival-camp/events{/privacy}","received_events_url":"https://api.github.com/users/rubizza-survival-camp/received_events","type":"Organization","site_admin":false},"repo":{"id":159675553,"node_id":"MDEwOlJlcG9zaXRvcnkxNTk2NzU1NTM=","name":"winter-2018","full_name":"rubizza-survival-camp/winter-2018","private":false,"owner":{"login":"rubizza-survival-camp","id":40864986,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQwODY0OTg2","avatar_url":"https://avatars1.githubusercontent.com/u/40864986?v=4","gravatar_id":"","url":"https://api.github.com/users/rubizza-survival-camp","html_url":"https://github.com/rubizza-survival-camp","followers_url":"https://api.github.com/users/rubizza-survival-camp/followers","following_url":"https://api.github.com/users/rubizza-survival-camp/following{/other_user}","gists_url":"https://api.github.com/users/rubizza-survival-camp/gists{/gist_id}","starred_url":"https://api.github.com/users/rubizza-survival-camp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rubizza-survival-camp/subscriptions","organizations_url":"https://api.github.com/users/rubizza-survival-camp/orgs","repos_url":"https://api.github.com/users/rubizza-survival-camp/repos","events_url":"https://api.github.com/users/rubizza-survival-camp/events{/privacy}","received_events_url":"https://api.github.com/users/rubizza-survival-camp/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/rubizza-survival-camp/winter-2018","description":null,"fork":false,"url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018","forks_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/forks","keys_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/teams","hooks_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/hooks","issue_events_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/issues/events{/number}","events_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/events","assignees_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/assignees{/user}","branches_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/branches{/branch}","tags_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/tags","blobs_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/git/refs{/sha}","trees_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/statuses/{sha}","languages_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/languages","stargazers_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/stargazers","contributors_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/contributors","subscribers_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/subscribers","subscription_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/subscription","commits_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/commits{/sha}","git_commits_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/git/commits{/sha}","comments_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/comments{/number}","issue_comment_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/issues/comments{/number}","contents_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/contents/{+path}","compare_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/merges","archive_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/downloads","issues_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/issues{/number}","pulls_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/pulls{/number}","milestones_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/milestones{/number}","notifications_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/labels{/name}","releases_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/releases{/id}","deployments_url":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/deployments","created_at":"2018-11-29T14:06:05Z","updated_at":"2018-12-03T16:20:59Z","pushed_at":"2018-12-09T11:28:08Z","git_url":"git://github.com/rubizza-survival-camp/winter-2018.git","ssh_url":"git@github.com:rubizza-survival-camp/winter-2018.git","clone_url":"https://github.com/rubizza-survival-camp/winter-2018.git","svn_url":"https://github.com/rubizza-survival-camp/winter-2018","homepage":null,"size":29,"stargazers_count":1,"watchers_count":1,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":25,"mirror_url":null,"archived":false,"open_issues_count":12,"license":null,"forks":25,"open_issues":12,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/pulls/1"},"html":{"href":"https://github.com/rubizza-survival-camp/winter-2018/pull/1"},"issue":{"href":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/issues/1"},"comments":{"href":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/rubizza-survival-camp/winter-2018/statuses/0b62c4fa8b1960ab0f7d61351ffae56fb08fa35c"}},"author_association":"NONE"}}
{"actor":{"display_login":"RGBD"}}