# Method use?

**URL:** <https://rubytalk.org/t/method-use/43015>\
**Category:** ruby-talk\
**Created:** [14 December 2007 15:17 UTC](https://rubytalk.org/t/method-use/43015 "2007-12-14T15:17:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ruby\_Geo](https://avatars.discourse-cdn.com/v4/letter/r/977dab/32.png) [@Ruby\_Geo](https://rubytalk.org/u/Ruby_Geo)\
**Post date:** [14 December 2007 15:17 UTC](https://rubytalk.org/t/method-use/43015/1 "2007-12-14T15:17:11Z")

</div>

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

&nbsp;&nbsp;&nbsp;def self.search\_by\_keyword(businesses, searched\_keyword)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;businesses.select do |b|  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b.my\_keywords.include?(searched\_keyword)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return  
&nbsp;&nbsp;&nbsp;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  
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Ruby\_Geo](https://avatars.discourse-cdn.com/v4/letter/r/977dab/32.png) [@Ruby\_Geo](https://rubytalk.org/u/Ruby_Geo)\
**Post date:** [14 December 2007 15:34 UTC](https://rubytalk.org/t/method-use/43015/2 "2007-12-14T15:34:43Z")

</div>

> I have this class method which takes 2 parameter and how can I use it to  
> print the input.
> 
> &nbsp;&nbsp;&nbsp;def self.search\_by\_keyword(businesses, searched\_keyword)  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;businesses.select do |b|  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b.my\_keywords.include?(searched\_keyword)  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return  
> &nbsp;&nbsp;&nbsp;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
> 
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
