# Partial Search

**URL:** <https://www.ruby-forum.com/t/partial-search/123391>\
**Category:** Ruby\
**Created:** [December 17, 2007, 10:40am UTC](https://www.ruby-forum.com/t/partial-search/123391 "2007-12-17T10:40:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ruby\_tl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c0e974/32.png) [@ruby\_tl](https://www.ruby-forum.com/u/ruby_tl)\
**Post date:** [December 17, 2007, 10:40am UTC](https://www.ruby-forum.com/t/partial-search/123391/1 "2007-12-17T10:40:07Z")

</div>

Can someone please help me to adjust the folowing method into  
displaying  
using a flag. Basically what I want it to do it have an array of  
keywords  
and a flag which asks partial match or exact

## These are the keywords.

KEYWORDS =[“Sole Trader”, “Retail”, “Builder”, “Internet”]

## And this is the current method.

def self.search\_by\_keyword(businesses, searched\_keyword)  
businesses.select do |b|  
b.my\_keywords.include?(searched\_keyword)  
end  
end

## It has to me something like this.

```
  def self.search_by_keyword(businesses, searched_keyword_as_array,

```

flag\_exact\_or\_partial\_match)  
businesses.select do |b|  
b.my\_keywords.include?(searched\_keyword)  
end  
en
