Class: Rubino::Documents::Converters::Csv
- Inherits:
-
Object
- Object
- Rubino::Documents::Converters::Csv
- Defined in:
- lib/rubino/documents/converters/csv.rb
Overview
CSV -> a GFM Markdown table (first row = header), via the shared Table emitter. ‘csv` was removed from Ruby’s default gems in 3.4, so we require it defensively: if it isn’t present we still parse with a tiny built-in splitter (handles the common quoted-field case) rather than going unavailable – CSV is too central to drop on a missing stdlib gem.
Instance Method Summary collapse
- #accepts?(mime, path) ⇒ Boolean
- #available? ⇒ Boolean
- #convert(path, budget = Limits.null_budget) ⇒ Object
Instance Method Details
#accepts?(mime, path) ⇒ Boolean
16 17 18 19 20 21 |
# File 'lib/rubino/documents/converters/csv.rb', line 16 def accepts?(mime, path) m = mime.to_s return true if ["text/csv", "application/csv"].include?(m) File.extname(path.to_s).downcase == ".csv" end |
#available? ⇒ Boolean
12 13 14 |
# File 'lib/rubino/documents/converters/csv.rb', line 12 def available? true end |
#convert(path, budget = Limits.null_budget) ⇒ Object
23 24 25 26 |
# File 'lib/rubino/documents/converters/csv.rb', line 23 def convert(path, budget = Limits.null_budget) rows = parse(path, budget) Table.emit(rows) end |