Search Array

R

Ruby Geo

Hi all.

I am trying to convert the folowing code into a class method. which
takes two argument. ! for keywords and another for business(callection
of classes). which both are arrays. And I am stack any help ? ?


objects = [bsn0, bsn1, bsn2, bsn3, bsn4]
search = ["Sole Trader"]
results = objects.select do |b|
match = true
catch:)success) do
search.each{|s| throw :success if b.my_keywords.include?(s) }
match = false
end
match

end
puts (" ")
puts "Search Results"
puts (" ")
results.each{|r| puts r }


'''''''''''''''''''''''''''''''''''''''''''''''''''



Attemted method



def self.search_type(key ,user)

objects = [bsn0, bsn1, bsn2, bsn3, bsn4]
#search = ["Sole Trader"]
#search = [KEYWORDS[0],KEYWORDS[1],KEYWORDS[2],KEYWORDS[3]]
results = objects.select do |b|
b.my_keywords.include?(search[0])

end

end
 

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

Refactor into a class method. 1
Printing result of class method 1
Partial Search 1
Partial Search 0
method use ? 1
Search keywords inside of directories and files 4
Crawling 1
Comparing/search struct array 1

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,592
Members
45,103
Latest member
VinaykumarnNevatia
Top