Class: ImportEverything::Preview

Inherits:
Object
  • Object
show all
Defined in:
lib/import_everything/preview.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ops) ⇒ Preview

Returns a new instance of Preview.



28
29
30
# File 'lib/import_everything/preview.rb', line 28

def initialize(ops)
  self.ops = ops
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &b) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/import_everything/preview.rb', line 48

def method_missing(sym,*args,&b)
  if sym.to_s[-1..-1] == '='
    self.ops[sym.to_s[0..-2]] = args.first
    dt!
  else
    super
  end
end

Instance Attribute Details

#opsObject

Returns the value of attribute ops.



27
28
29
# File 'lib/import_everything/preview.rb', line 27

def ops
  @ops
end

Instance Method Details

#addl_required_fieldsObject



35
36
37
# File 'lib/import_everything/preview.rb', line 35

def addl_required_fields
  parser.addl_required_fields
end

#parserObject



32
33
34
# File 'lib/import_everything/preview.rb', line 32

def parser
  dt.parser
end

#preview_tableObject



41
42
43
# File 'lib/import_everything/preview.rb', line 41

def preview_table
  DisplayTable.new(:rows => parser.cleaned_value_hashes)
end

#ready?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/import_everything/preview.rb', line 38

def ready?
  addl_required_fields.empty?
end

#tableObject



44
# File 'lib/import_everything/preview.rb', line 44

def table; preview_table; end

#tablesObject



45
46
47
# File 'lib/import_everything/preview.rb', line 45

def tables
  parser.table_rows_hash.map { |table,rows| DisplayTable.new(:table => table, :rows => rows) }
end