Skip to content

Commit

Permalink
refactoring (#541)
Browse files Browse the repository at this point in the history
* refactoring

* refactoring
  • Loading branch information
suketa authored Oct 14, 2023
1 parent 423a286 commit 7a7bd17
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/duckdb/result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module DuckDB
class Result
include Enumerable

ToRuby = {
TO_METHODS = Hash.new(:_to_string).merge(
1 => :_to_boolean,
3 => :_to_smallint,
4 => :_to_integer,
Expand All @@ -35,9 +35,7 @@ class Result
16 => :_to_hugeint_internal,
18 => :_to_blob,
19 => :_to_decimal_internal
}

ToRuby.default = :_to_string
).freeze

alias column_size column_count
alias row_size row_count
Expand Down Expand Up @@ -76,7 +74,7 @@ def row(row_index)
end

def to_value(row_index, col_index)
send(ToRuby[_column_type(col_index)], row_index, col_index)
send(TO_METHODS[_column_type(col_index)], row_index, col_index)
end

def enum_dictionary_values(col_index)
Expand Down

0 comments on commit 7a7bd17

Please sign in to comment.