Class: Massive::File
- Inherits:
-
Object
- Object
- Massive::File
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- lib/massive/file.rb
Instance Method Summary collapse
Instance Method Details
#gather_info! ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/massive/file.rb', line 23 def gather_info! clear_info self.encoding = processor.detected_encoding self.col_sep = processor.col_sep self.total_count = processor.total_count self.headers = processor.shift && processor.headers if use_headers? processor.process_range(limit: 3) do |row| self.sample_data << (use_headers? ? row.fields : row) end save end |
#has_info? ⇒ Boolean
38 39 40 |
# File 'lib/massive/file.rb', line 38 def has_info? [:encoding, :col_sep, :total_count].all? { |field| send(field).present? } end |
#processor ⇒ Object
19 20 21 |
# File 'lib/massive/file.rb', line 19 def processor @processor ||= FileProcessor::CSV.new(url, ) end |
#url ⇒ Object
42 43 44 |
# File 'lib/massive/file.rb', line 42 def url read_attribute(:url).presence || authenticator.url end |