Class: Correios::Setup

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

Overview

Handles building the in memory store of CEP data

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSetup



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ceps/setup.rb', line 18

def initialize
  @data_file_name = 'ceps.yaml'
  if defined?(Rails)
    @data_file_path = File.join(Rails.root, "lib", "data")
  else
    @data_file_path = File.join( 
                        File.dirname(
                        File.dirname(__FILE__)),
                        "lib", "data")
  end
  @data_file = File.join @data_file_path, @data_file_name
end

Instance Attribute Details

#data_fileObject

Returns the value of attribute data_file.



11
12
13
# File 'lib/ceps/setup.rb', line 11

def data_file
  @data_file
end

#data_file_nameObject

Returns the value of attribute data_file_name.



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

def data_file_name
  @data_file_name
end

#data_file_pathObject

Returns the value of attribute data_file_path.



9
10
11
# File 'lib/ceps/setup.rb', line 9

def data_file_path
  @data_file_path
end

Instance Method Details

#cepsObject



13
14
15
16
# File 'lib/ceps/setup.rb', line 13

def ceps
  return @ceps if instance_variable_defined?('@ceps')
  @ceps ||= load
end