mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 23:52:35 +00:00
Restructured Model loading to enable easier implementation of other parsers
This commit is contained in:
30
lib/model/parser.rb
Normal file
30
lib/model/parser.rb
Normal file
@@ -0,0 +1,30 @@
|
||||
class IMICFPS
|
||||
class Model
|
||||
class Parser
|
||||
@@parsers = []
|
||||
|
||||
def self.handles
|
||||
raise NotImplementedError, "Model::Parser#handles must return an array of file extensions that this parser supports"
|
||||
end
|
||||
|
||||
def self.inherited(parser)
|
||||
@@parsers << parser
|
||||
end
|
||||
|
||||
def self.find(file_type)
|
||||
found_parser = @@parsers.find do |parser|
|
||||
parser.handles.include?(file_type)
|
||||
end
|
||||
|
||||
return found_parser
|
||||
end
|
||||
|
||||
def initialize(model)
|
||||
@model = model
|
||||
end
|
||||
|
||||
def parse
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user