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 = {size_batch: 1000, sep: ";", initial: false}) ⇒ Importeer

Returns a new instance of Importeer.



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

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

Instance Attribute Details

#dirObject

Returns the value of attribute dir.



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

def dir
  @dir
end

#initialObject

Returns the value of attribute initial.



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

def initial
  @initial
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#pathObject

Returns the value of attribute path.



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

def path
  @path
end

#sepObject

Returns the value of attribute sep.



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

def sep
  @sep
end

#size_batchObject

Returns the value of attribute size_batch.



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

def size_batch
  @size_batch
end

Class Method Details

.dirObject



20
21
22
# File 'lib/importeer_plan.rb', line 20

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

Instance Method Details

#bronObject



24
25
# File 'lib/importeer_plan.rb', line 24

def bron
end

#commaf(str) ⇒ Object

comma-float; “1,234”



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

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

#importeerObject



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

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

#pointf(str) ⇒ Object

point-float; “1.234”



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

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