From f0fcee9bc3f5e1ef6dc824044bf4df8748510507 Mon Sep 17 00:00:00 2001 From: Arsalan Ahmed Date: Mon, 25 May 2015 15:18:00 -0400 Subject: [PATCH] Solved using case and regexp --- Gemfile.lock | 30 ------------------------------ parser.rb | 9 ++++++++- 2 files changed, 8 insertions(+), 31 deletions(-) delete mode 100644 Gemfile.lock diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index e283e8f..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,30 +0,0 @@ -GEM - remote: http://rubygems.org/ - specs: - coderay (1.1.0) - diff-lcs (1.2.5) - method_source (0.8.2) - pry (0.10.1) - coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) - rspec (3.1.0) - rspec-core (~> 3.1.0) - rspec-expectations (~> 3.1.0) - rspec-mocks (~> 3.1.0) - rspec-core (3.1.4) - rspec-support (~> 3.1.0) - rspec-expectations (3.1.2) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.1.0) - rspec-mocks (3.1.2) - rspec-support (~> 3.1.0) - rspec-support (3.1.1) - slop (3.6.0) - -PLATFORMS - ruby - -DEPENDENCIES - pry - rspec diff --git a/parser.rb b/parser.rb index adaad3e..8f93cea 100644 --- a/parser.rb +++ b/parser.rb @@ -1,3 +1,10 @@ def word_in_string?(word, string) - # implement with your code here + case string + when Regexp.new('\b' + word + '\b') + :yes + when Regexp.new("_+#{word}_+|#{word}_+|_+#{word}") + :yes + else + :no + end end