Class: Kwatable::Manipulator
- Inherits:
-
Object
- Object
- Kwatable::Manipulator
- Includes:
- Assertion
- Defined in:
- lib/kwatable/manipulator.rb
Overview
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Manipulator
constructor
A new instance of Manipulator.
-
#manipulate(tabledef) ⇒ Object
def parse(input) str = ” input.each_line do |line| str << line.gsub(/(8)|([^t]*)t/n)[$+][$+].pack(“A8”) ## expand tab end tabledef = YAML.load(str) manipulate(tabledef) return tabledef end.
Methods included from Assertion
Constructor Details
#initialize(options = {}) ⇒ Manipulator
Returns a new instance of Manipulator.
27 28 29 |
# File 'lib/kwatable/manipulator.rb', line 27 def initialize(={}) @overridable = [:overridable] end |
Instance Method Details
#manipulate(tabledef) ⇒ Object
def parse(input)
str = ''
input.each_line do |line|
str << line.gsub(/([^\t]{8})|([^\t]*)\t/n){[$+].pack("A8")} ## expand tab
end
tabledef = YAML.load(str)
manipulate(tabledef)
return tabledef
end
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/kwatable/manipulator.rb', line 41 def manipulate(tabledef) #assert unless tabledef.is_a?(Hash) return tabledef unless tabledef.is_a?(Hash) column_map, patterned_columns = _manipulate_columns(tabledef['columns']) #assert unless column_map.is_a?(Hash) #assert unless patterned_columns.is_a?(Array) table_map = _manipulate_tables(tabledef['tables'], column_map, patterned_columns) #assert unless table_map.is_a?(Hash) tabledef['column_map'] = column_map # Hash tabledef['table_map'] = table_map # Hash return tabledef end |