method use ?

Discussion in 'Ruby' started by Ruby Geo, Dec 14, 2007.

  1. Ruby Geo

    Ruby Geo Guest

    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-forum.com/.
     
    Ruby Geo, Dec 14, 2007
    #1
    1. Advertising

  2. Ruby Geo

    Ruby Geo Guest


    > 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-forum.com/.
     
    Ruby Geo, Dec 14, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jerry051
    Replies:
    2
    Views:
    755
    Oliver Sturm
    Aug 2, 2005
  2. Mike Wilmot
    Replies:
    0
    Views:
    3,292
    Mike Wilmot
    Dec 15, 2003
  3. CW
    Replies:
    0
    Views:
    566
  4. _Who
    Replies:
    7
    Views:
    2,685
  5. Kyung won Cheon
    Replies:
    0
    Views:
    208
    Kyung won Cheon
    Nov 21, 2008
Loading...

Share This Page