Class: ODDB::Import::Importer
- Inherits:
-
Object
- Object
- ODDB::Import::Importer
show all
- Defined in:
- lib/oddb/import/importer.rb
Constant Summary
collapse
- @@iconv =
Iconv.new('utf8//IGNORE//TRANSLIT', 'latin1')
- @@lower =
/^(and|for|in(cl)?|on|plain|with)$/i
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Importer.
10
11
12
13
|
# File 'lib/oddb/import/importer.rb', line 10
def initialize
@report = []
@skip_rows = 1
end
|
Instance Attribute Details
#report ⇒ Object
Returns the value of attribute report.
9
10
11
|
# File 'lib/oddb/import/importer.rb', line 9
def report
@report
end
|
Instance Method Details
#capitalize_all(str) ⇒ Object
14
15
16
17
18
|
# File 'lib/oddb/import/importer.rb', line 14
def capitalize_all(str)
str.split(/\b/).collect { |part|
@@lower.match(part) ? part.downcase : part.capitalize }.join
end
|
#company_name(cname) ⇒ Object
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/oddb/import/importer.rb', line 19
def company_name(cname)
cname = capitalize_all(cname.to_s)
cname.gsub!(/\.(?!\s)/, '. ')
cname.gsub!(/[\/&]/) { |match| ' %s ' % match }
cname.gsub!(/Gmbh/, 'GmbH')
cname.gsub!(/Ag\b/, 'AG')
cname.gsub!(/\bKg\b/, 'KG')
cname.strip!
u(cname)
end
|
#postprocess ⇒ Object
29
30
|
# File 'lib/oddb/import/importer.rb', line 29
def postprocess
end
|
#utf8(str) ⇒ Object
31
32
33
|
# File 'lib/oddb/import/importer.rb', line 31
def utf8(str)
u @@iconv.iconv(str) if str
end
|