Class: ChainReactor::ParserFactory
- Inherits:
-
Object
- Object
- ChainReactor::ParserFactory
- Defined in:
- lib/chain-reactor/parser_factory.rb
Overview
Used to parse strings using a method defined by child classes.
Class Method Summary collapse
-
.get_parser(type, logger) ⇒ Object
Class method for retrieving a new Parser object depending on the type variable.
Class Method Details
.get_parser(type, logger) ⇒ Object
Class method for retrieving a new Parser object depending on the type variable.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/chain-reactor/parser_factory.rb', line 11 def self.get_parser(type,logger) class_name = type.to_s.capitalize if class_name.include? "_" class_name = class_namesplit('_').map{|e| e.capitalize}.join end parser_class_name = class_name + 'Parser' logger.debug { "Creating parser: #{parser_class_name}" } parser_class = ChainReactor::Parsers.const_get parser_class_name parser_class.new(logger) end |