Class: ChupaText::Decomposers::CSV
Instance Method Summary
collapse
#initialize, registry
Instance Method Details
#decompose(data) {|text_data| ... } ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/chupa-text/decomposers/csv.rb', line 29
def decompose(data)
text = ""
data.open do |input|
csv = ::CSV.new(input)
csv.each do |row|
text << row.join(" ")
text << "\n"
end
end
text_data = TextData.new(text)
text_data.uri = data.uri
yield(text_data)
end
|
#target?(data) ⇒ Boolean
24
25
26
27
|
# File 'lib/chupa-text/decomposers/csv.rb', line 24
def target?(data)
data.extension == "csv" or
data.mime_type == "text/csv"
end
|