Class: Importer::Parser::Base
- Inherits:
-
Object
- Object
- Importer::Parser::Base
- Defined in:
- lib/importer/parser/base.rb
Overview
Extend this class if you want to provide a custom parser. You only need to implement run instance method in subclasses.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Class Method Summary collapse
-
.run(file) ⇒ Object
Creates parser instance and processes the
file.
Instance Method Summary collapse
-
#initialize(file) ⇒ Base
constructor
A new instance of Base.
-
#run ⇒ Object
This method must be implemented in subclasses.
Constructor Details
#initialize(file) ⇒ Base
Returns a new instance of Base.
18 19 20 21 |
# File 'lib/importer/parser/base.rb', line 18 def initialize(file) @file = file @data = [] end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
16 17 18 |
# File 'lib/importer/parser/base.rb', line 16 def data @data end |
Class Method Details
.run(file) ⇒ Object
Creates parser instance and processes the file
9 10 11 12 13 |
# File 'lib/importer/parser/base.rb', line 9 def run(file) parser = new(file) parser.run parser.data end |
Instance Method Details
#run ⇒ Object
This method must be implemented in subclasses. It is meant to process input @file, and store the results in @data instance variable.
26 27 28 |
# File 'lib/importer/parser/base.rb', line 26 def run raise Exception.new("This method must be implemented in subclasses.") end |