Class: CSVGeocoder::Sources::CSV
- Inherits:
-
Object
- Object
- CSVGeocoder::Sources::CSV
- Defined in:
- lib/csv_geocoder/sources/csv.rb
Instance Method Summary collapse
- #ask ⇒ Object
-
#initialize(prompt) ⇒ CSV
constructor
A new instance of CSV.
Constructor Details
#initialize(prompt) ⇒ CSV
Returns a new instance of CSV.
5 6 7 |
# File 'lib/csv_geocoder/sources/csv.rb', line 5 def initialize(prompt) @prompt = prompt end |
Instance Method Details
#ask ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/csv_geocoder/sources/csv.rb', line 9 def ask csv = nil until csv begin csv_path = @prompt.ask("Hi, whats the path to your CSV?", required: true) csv ||= ::CSV.read(csv_path, headers: true) rescue Errno::ENOENT @prompt.error "Thats not a valid CSV path, please enter it again" @prompt.warn "If you're on mac, right click the file, hold option, then click copy as pathname" end end csv end |