Class: Correios::Setup
- Inherits:
-
Object
- Object
- Correios::Setup
- Defined in:
- lib/ceps/setup.rb
Overview
Handles building the in memory store of CEP data
Instance Attribute Summary collapse
-
#data_file ⇒ Object
Returns the value of attribute data_file.
-
#data_file_name ⇒ Object
Returns the value of attribute data_file_name.
-
#data_file_path ⇒ Object
Returns the value of attribute data_file_path.
Instance Method Summary collapse
- #ceps ⇒ Object
-
#initialize ⇒ Setup
constructor
A new instance of Setup.
Constructor Details
#initialize ⇒ Setup
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_file ⇒ Object
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_name ⇒ Object
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_path ⇒ Object
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
#ceps ⇒ Object
13 14 15 16 |
# File 'lib/ceps/setup.rb', line 13 def ceps return @ceps if instance_variable_defined?('@ceps') @ceps ||= load end |