[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

method use ?

Ruby Geo

12/14/2007 3:17:00 PM

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
--
Posted via http://www.ruby-....

1 Answer

Ruby Geo

12/14/2007 3:35:00 PM

0


> 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

--
Posted via http://www.ruby-....