I’m developing an application where I need to extract text from a number
of different file formats. To this end I would like to create a Parser
class that will be reusable and handle all of the heavy lifting.
Ideally I would like to do something like this (sorry for any code
my_rtf_parser = Parser.new(‘path/to/rtf_file.rtf’)
my_text = my_rtf_parser.to_text
my_pdf_parser = Parser.new(‘path/to/pdf_file.pdf’)
my_text = my_pdf_parser.to_text
The Parser class should be able to determine the correct type for the
file being passed to it and then load up the “to_text” method
appropriate to that file type.
What is the best way to separate out the classes that will perform these
action and where should I locate the files in the Rails directory
Thanks in advance for the assistance.