Class: ImporteerPlan::Importeer

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

Direct Known Subclasses

MyCsv, MyTxt, MyXls

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Importeer

Returns a new instance of Importeer.



13
14
15
16
17
18
19
20
# File 'lib/importeer_plan.rb', line 13

def initialize(name, options={})
	@options = options
	@name = name
	@path = Importeer.dir.join( @name ) 
	@size_batch = options[:size_batch]||1000
	@sep = options[:sep]|| ";"
	@initial = options[:initial]|| false
end

Instance Attribute Details

#dirObject

Returns the value of attribute dir.



8
9
10
# File 'lib/importeer_plan.rb', line 8

def dir
  @dir
end

#initialObject

Returns the value of attribute initial.



8
9
10
# File 'lib/importeer_plan.rb', line 8

def initial
  @initial
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/importeer_plan.rb', line 8

def name
  @name
end

#optionsObject

Returns the value of attribute options.



8
9
10
# File 'lib/importeer_plan.rb', line 8

def options
  @options
end

#pathObject

Returns the value of attribute path.



8
9
10
# File 'lib/importeer_plan.rb', line 8

def path
  @path
end

#sepObject

Returns the value of attribute sep.



8
9
10
# File 'lib/importeer_plan.rb', line 8

def sep
  @sep
end

#size_batchObject

Returns the value of attribute size_batch.



8
9
10
# File 'lib/importeer_plan.rb', line 8

def size_batch
  @size_batch
end

Class Method Details

.dirObject



22
23
24
25
26
27
# File 'lib/importeer_plan.rb', line 22

def self.dir
	# Rails.root.join('public/imports/')

	ImporteerPlan.configuration.dir

end

Instance Method Details

#bronObject



29
30
# File 'lib/importeer_plan.rb', line 29

def bron
end

#commaf(str) ⇒ Object

comma-float; “1,234”



40
41
42
# File 'lib/importeer_plan.rb', line 40

def commaf(str) # comma-float; "1,234" 
	   ('%.2f' % str.gsub(',', '.') ).to_f
end

#importeerObject



35
36
37
38
# File 'lib/importeer_plan.rb', line 35

def importeer
	sweep
	bron.each{|batch| importeer_batch batch}
end

#pointf(str) ⇒ Object

point-float; “1.234”



44
45
46
# File 'lib/importeer_plan.rb', line 44

def pointf(str) # point-float; "1.234"
	   ('%.2f' % str.gsub(',', '.') ).to_f
end

#sweepObject



32
33
# File 'lib/importeer_plan.rb', line 32

def sweep
end