Hi..
I have two methods.but the parameter will be changing.
For the first method i send only one parameter(f).
But for the second method i'll send 3
parameters(f,search_string_1,search_string_2).
And also for 3rd Method i send Two Parameter(f,search_string).

Is it possible to optimise below methods into Single Methods .
How can i combine the below Three Methods into one method pls help me.


#method 1
def check_chat_type(f)
 Dir.foreach(File.join(RAILS_ROOT +
"/public/ACMServer_exe/ChatHistory",f)) do sub_folder_name|
   if sub_folder_name.include? "Vs"
     get_path(f,sub_folder_name)
   end
 end
end

#method 2
def check_chat_type(f,search_string_1,search_string_2)
  Dir.foreach(File.join(RAILS_ROOT +
"/public/ACMServer_exe/ChatHistory",f)) do
  |sub_folder_name|
    if sub_folder_name.include? "Vs"
      if sub_folder_name.include?(search_string_1)
        if sub_folder_name.include?(search_string_2)
          get_path(f,sub_folder_name)
        end
      end
    end
  end
end

#Method 3
def check_chat_type(f,search_string)
  Dir.foreach(File.join(RAILS_ROOT +
"/public/ACMServer_exe/ChatHistory",f)) do
  |sub_folder_name|
    if sub_folder_name.include? "Vs"
      if sub_folder_name.include?(search_string)
        get_path(f,sub_folder_name)
      end
    end
  end
end
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to