Class: DBA::RowParser

Inherits:
Object
  • Object
show all
Defined in:
lib/dba/row_parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(table_schema) ⇒ RowParser

Returns a new instance of RowParser.



7
8
9
# File 'lib/dba/row_parser.rb', line 7

def initialize(table_schema)
  @table_schema = table_schema
end

Instance Method Details

#parse(string) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/dba/row_parser.rb', line 11

def parse(string)
  string.strip.split("\n").each_with_object({}) do |line, hash|
    key, value = line.split(/:\s*/, 2)

    column_name = key.to_sym

    hash[column_name] = value_parse(column_name, value)
  end
end