Class: Loadfile::OptParser
- Inherits:
-
Object
- Object
- Loadfile::OptParser
- Defined in:
- lib/opticon/opt_parser.rb
Overview
This class converts an opticon text file or data stream to an instance of Opticon
Instance Method Summary collapse
-
#initialize ⇒ OptParser
constructor
Create a new parser for Opticon.
-
#parse(input) ⇒ Object
Parse text from IO object
input.
Constructor Details
#initialize ⇒ OptParser
Create a new parser for Opticon
12 13 14 |
# File 'lib/opticon/opt_parser.rb', line 12 def initialize @records = [] end |
Instance Method Details
#parse(input) ⇒ Object
Parse text from IO object input. It is the caller’s responsibility to open and close the input correctly.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/opticon/opt_parser.rb', line 20 def parse input c_doc = [] while line = input.gets l = line.chomp.split(',') c_record = { :key => l[0], :volume => l[1], :path => l[2], :break => l[3], :empty1 => l[4], :empty2 => l[5], :pages => l[6], } @records.push c_record end Loadfile::Opticon.new @records end |