Skip to content

Commit

Permalink
Merge pull request #55 from ledermann/accept_big_decimal_as_number
Browse files Browse the repository at this point in the history
DataTable: Accept BigDecimal as number
  • Loading branch information
winston committed Jan 19, 2013
2 parents 29b6fd2 + 99ec020 commit 651884f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/google_visualr/data_table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def verify_against_column_type(type, value)
when type == "string"
raise ArgumentError, "cell value '#{v}' is not a String", caller unless v.is_a?(String)
when type == "number"
raise ArgumentError, "cell value '#{v}' is not an Integer or a Float", caller unless v.is_a?(Integer) || v.is_a?(Float)
raise ArgumentError, "cell value '#{v}' is not an Integer, Float or BigDecimal", caller unless v.is_a?(Integer) || v.is_a?(Float) || v.is_a?(BigDecimal)
when type == "boolean"
raise ArgumentError, "cell value '#{v}' is not a Boolean", caller unless v.is_a?(TrueClass) || v.is_a?(FalseClass)
when type == 'datetime'
Expand Down
6 changes: 6 additions & 0 deletions spec/google_visualr/data_table_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ def assert_raises_exception(col, value)
it "raises an exception if value is not date" do
assert_raises_exception(4, 'ABCD')
end

it "accepts BigDecimal as number" do
expect {
dt.set_cell(0, 1, BigDecimal.new(42))
}.to_not raise_exception(ArgumentError)
end
end

it "accepts 'nil' for all column types" do
Expand Down

0 comments on commit 651884f

Please sign in to comment.