Class: RateCenter::DataLoader
- Inherits:
-
Object
- Object
- RateCenter::DataLoader
- Defined in:
- lib/rate_center/data_loader.rb
Instance Attribute Summary collapse
-
#cities ⇒ Object
readonly
Returns the value of attribute cities.
-
#data_directory ⇒ Object
readonly
Returns the value of attribute data_directory.
-
#lata ⇒ Object
readonly
Returns the value of attribute lata.
-
#rate_centers ⇒ Object
readonly
Returns the value of attribute rate_centers.
Instance Method Summary collapse
-
#initialize(**options) ⇒ DataLoader
constructor
A new instance of DataLoader.
- #load(type) ⇒ Object
Constructor Details
#initialize(**options) ⇒ DataLoader
Returns a new instance of DataLoader.
7 8 9 |
# File 'lib/rate_center/data_loader.rb', line 7 def initialize(**) @data_directory = .fetch(:data_directory) { Pathname(File.("../../data/", __dir__)) } end |
Instance Attribute Details
#cities ⇒ Object (readonly)
Returns the value of attribute cities.
5 6 7 |
# File 'lib/rate_center/data_loader.rb', line 5 def cities @cities end |
#data_directory ⇒ Object (readonly)
Returns the value of attribute data_directory.
5 6 7 |
# File 'lib/rate_center/data_loader.rb', line 5 def data_directory @data_directory end |
#lata ⇒ Object (readonly)
Returns the value of attribute lata.
5 6 7 |
# File 'lib/rate_center/data_loader.rb', line 5 def lata @lata end |
#rate_centers ⇒ Object (readonly)
Returns the value of attribute rate_centers.
5 6 7 |
# File 'lib/rate_center/data_loader.rb', line 5 def rate_centers @rate_centers end |
Instance Method Details
#load(type) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rate_center/data_loader.rb', line 11 def load(type, ...) case type.to_sym when :all @cities = load_data("cities", :all) @rate_centers = load_data("rate_centers", :all) when :cities @cities = load_data("cities", ...) when :rate_centers @rate_centers = load_data("rate_centers", ...) when :lata @lata = load_data("lata", ...) else raise ArgumentError, "Invalid type: #{type}" end nil end |