Skip to content

Commit

Permalink
Merge pull request #350 from lonnieking/csv-set-value
Browse files Browse the repository at this point in the history
Cell values can be set in a CSV
  • Loading branch information
stevendaniels committed Nov 15, 2016
2 parents cc0d1ec + 85bcc05 commit 0f67aa1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/roo/csv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ def csv_options
@options[:csv_options] || {}
end

def set_value(row, col, value, _sheet)
@cell[[row, col]] = value
end

def set_type(row, col, type, _sheet)
@cell_type[[row, col]] = type
end

private

TYPE_MAP = {
Expand Down
12 changes: 12 additions & 0 deletions spec/lib/roo/csv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,16 @@
end
end
end

describe '#set_value' do
it 'returns the cell value' do
expect(csv.set_value('A', 1, 'some-value', nil)).to eq('some-value')
end
end

describe '#set_type' do
it 'returns the cell type' do
expect(csv.set_type('A', 1, 'some-type', nil)).to eq('some-type')
end
end
end

0 comments on commit 0f67aa1

Please sign in to comment.