Class: ODDB::Import::GkvHandler
- Inherits:
-
Rpdf2txt::SimpleHandler
- Object
- Rpdf2txt::SimpleHandler
- ODDB::Import::GkvHandler
- Defined in:
- lib/oddb/import/gkv.rb
Instance Attribute Summary collapse
-
#pairs ⇒ Object
readonly
Returns the value of attribute pairs.
Instance Method Summary collapse
-
#initialize(callback) ⇒ GkvHandler
constructor
A new instance of GkvHandler.
- #reset ⇒ Object
- #send_flowing_data(data) ⇒ Object
- #send_line_break ⇒ Object
- #send_page ⇒ Object
Constructor Details
#initialize(callback) ⇒ GkvHandler
Returns a new instance of GkvHandler.
16 17 18 19 20 |
# File 'lib/oddb/import/gkv.rb', line 16 def initialize callback @callback = callback @rows = [] reset end |
Instance Attribute Details
#pairs ⇒ Object (readonly)
Returns the value of attribute pairs.
15 16 17 |
# File 'lib/oddb/import/gkv.rb', line 15 def pairs @pairs end |
Instance Method Details
#reset ⇒ Object
21 22 23 |
# File 'lib/oddb/import/gkv.rb', line 21 def reset @current_line = '' end |
#send_flowing_data(data) ⇒ Object
24 25 26 |
# File 'lib/oddb/import/gkv.rb', line 24 def send_flowing_data(data) @current_line << data end |
#send_line_break ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/oddb/import/gkv.rb', line 27 def send_line_break data = @current_line.strip.split /\s{3,}/ if /^\d{6,}$/.match(data[1].to_s) ## ensure consistent row-length, so we can append additional substances # to the tail data[9] ||= nil @rows.push data else @rows.push :doubtful end reset end |
#send_page ⇒ Object
39 40 41 42 43 |
# File 'lib/oddb/import/gkv.rb', line 39 def send_page @callback.call @rows @rows = [] reset end |