# Method use?

**URL:** <https://www.ruby-forum.com/t/method-use/123167>\
**Category:** Ruby\
**Created:** [December 14, 2007, 4:17pm UTC](https://www.ruby-forum.com/t/method-use/123167 "2007-12-14T16:17:13Z")\
**Posts on this page:** 2\
**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 14, 2007, 4:17pm UTC](https://www.ruby-forum.com/t/method-use/123167/1 "2007-12-14T16:17:13Z")

</div>

I have this class method which takes 2 parameter and how can I use it to  
print the  
input.

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

* * *

e.g

Array outside the class  
KEYWORDS =[“Sole Trader”, “Retail”, “Builder”, “Internet”]

objects and asocieted keywords

bsn1 = Business.new(“Steve”, “02089293323”, "22 lilly Road "  
bsn1.add\_keyword(KEYWORDS[0])  
bsn1.add\_keyword(KEYWORDS[2])  
bsn1.add\_keyword(KEYWORDS[3])  
puts bsn1.to\_s

* * *

using the above method I want to display the business that contain a  
keyword.

Thank YOu

---

<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 14, 2007, 4:34pm UTC](https://www.ruby-forum.com/t/method-use/123167/2 "2007-12-14T16:34:47Z")

</div>

> I have this class method which takes 2 parameter and how can I use it to  
> print the input.
> 
> def self.search\_by\_keyword(businesses, searched\_keyword)  
> businesses.select do |b|  
> b.my\_keywords.include?(searched\_keyword)  
> end  
> return  
> end
> 
> * * *
> 
> e.g
> 
> Array outside the class  
> KEYWORDS =[“Sole Trader”, “Retail”, “Builder”, “Internet”]
> 
> objects and asocieted keywords
> 
> bsn1 = Business.new(“Steve”, “02089293323”, "22 lilly Road "  
> bsn1.add\_keyword(KEYWORDS[0])  
> bsn1.add\_keyword(KEYWORDS[2])  
> bsn1.add\_keyword(KEYWORDS[3])  
> puts bsn1.to\_s

bsn4 = Business.new(“Laura”, “02078982323”, "100 Abbey Road ")  
bsn4.add\_keyword(KEYWORDS[0])  
bsn4.add\_keyword(KEYWORDS[2])  
puts bsn4.to\_s

> * * *
> 
> using the above method I want to display the business that contain a  
> keyword.
> 
> Thank YOu
