method use ?

R

Ruby Geo

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
 
R

Ruby Geo

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Partial Search 1
Printing result of class method 1
Search Array 0
Checking results 0
Refactor into a class method. 1
Partial Search 0
Metho Error 2
Tasks 1

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top