Class: Fias::Import::Dbf

Inherits:
Object
  • Object
show all
Defined in:
lib/fias/import/dbf.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, encoding = DEFAULT_ENCODING) ⇒ Dbf

Returns a new instance of Dbf.



4
5
6
7
8
9
10
11
12
13
# File 'lib/fias/import/dbf.rb', line 4

def initialize(path, encoding = DEFAULT_ENCODING)
  @path = path
  @files = {}

  unless Dir.exist?(@path)
    fail ArgumentError, "FIAS database path #{@path} does not exists"
  end

  open_files(encoding)
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



29
30
31
# File 'lib/fias/import/dbf.rb', line 29

def files
  @files
end

Instance Method Details

#only(*names) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fias/import/dbf.rb', line 15

def only(*names)
  return @files if names.empty?

  names = names.map do |name|
    name = name.to_sym
    name == :houses ? HOUSE_TABLES.keys : name
    name == :nordocs ? NORDOC_TABLES.keys : name
  end

  names.flatten!

  @files.slice(*names)
end